dockerfile: how use CMD or ENTRYPOINT from base image dockerfile: how use CMD or ENTRYPOINT from base image docker docker

dockerfile: how use CMD or ENTRYPOINT from base image


If you left it blank in your new Dockerfile, it will inherit the one from the base image.

For example:

base

FROM ubuntuCMD ["echo", "AAA"]

layer1

FROM base

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

$ sudo docker run -it layer1AAA


@Vor is right. But in case

# DockerfileFROM nginx:stable-alpineENTRYPOINT ["/docker-entrypoint.sh"]COPY ./docker-entrypoint.sh /

and

# docker-entrypoint.sh#!/usr/bin/env shset -eexec "$@"

the default CMD from nginx:stable-alpine won't be executed in exec "$@".

You must to write default nginx-alpine's CMD by yourself(!) in Dockerfile

# DockerfileFROM nginx:stable-alpineENTRYPOINT ["/docker-entrypoint.sh"]CMD ["nginx", "-g", "daemon off;"]COPY ./docker-entrypoint.sh /

OR change your docker-entrypoint.sh

# docker-entrypoint.sh#!/usr/bin/env shset -eexec nginx -g "daemon off;"

Hope it helps