How to extend an existing docker image?

前端 未结 3 989
闹比i
闹比i 2020-12-05 17:03

I\'m using the official elasticsearch Docker image instead of setting up my own elastic search instance. And that works great, up to the point when I wanted to extend it. I

3条回答
  •  长情又很酷
    2020-12-05 17:44

    If you don't mind using docker-compose, what I usually do is to add a first section for the base image you plan to reuse, and then use that image as the base in the rest of the services' Dockerfiles, something along the lines of:

    ---
    version: '2'
    services:
        base:
            build: ./images/base
    
        collector:
             build: ./images/collector
    

    Then, in images/collector/Dockerfile, and since my project is called webtrack, I'd type

    FROM webtrack_base
    ...
    

    And now it's done!

提交回复
热议问题