Dockerfile: how to use CMD or ENTRYPOINT from a base image

I have some basic docker images that do not belong to me (therefore, I cannot change them). However, I create new images from them with added things.

I cannot figure out how to tell dockerfile to copy the CMD (or ENTRYPOINT) of the base image. Something like that:

FROM other:latest RUN my-extra-install CMD <use-the-CMD-from-base-image> 

I don’t think that any direct syntax for the CMD command to do what I want. I wonder if a workaround.

+5
source share
1 answer

If you leave it blank in your new Docker file, it inherits the one that is in the base image.

For instance:

the base

 FROM ubuntu CMD ["echo", "AAA"] 

layer1

 FROM base 

If you create above the images and run layer1 , you will get the following:

 $ sudo docker run -it layer1 AAA 
+7
source

Source: https://habr.com/ru/post/1266374/


All Articles