How do I combine several images into one?

2019-02-18 07:28发布

I have several images (3rd parties) which eg setup a mysql, set up a generic php app environment, set up 3rd parties tools.

I want to make a Dockerfile / Docker Image which combines both those images and then runs some more commands

imageA --
            \
imageV --    ---> sharedImageA..X
            /
imageX --

2条回答
看我几分像从前
2楼-- · 2019-02-18 08:11

You can chain them. You can find more here

https://github.com/docker/docker/issues/3378#issuecomment-31314906

Taken from the above link

## Dockerfile.genericwebapp might have FROM ubuntu
cat Dockerfile.genericwebapp | docker build -t genericwebapp -
## Dockerfile.genericpython-web would have FROM genericwebapp
cat Dockerfile.genericpython-web | docker build -t genericpython-web -
## and then this specific app i'm testing might have a docker file that containers FROM genericpython-web
docker build -t thisapp .

author of the above SvenDowideit

In general though, it's a bad practice to have more than one running processes on the same container.

查看更多
叛逆
3楼-- · 2019-02-18 08:11

Since dependencies from seconds and third image can conflict with dependencies from first image, I don't think docker would able to support it.

I guess the only option is to start your image from 1 of them an then install/run all of the steps from 2 others:

FROM imageA
RUN .... commands for imageV
RUN .... commands for imageX
查看更多
登录 后发表回答