I saw for example in the Dockerfile of the postgres image (https://github.com/docker-library/postgres/blob/master/10/Dockerfile) that at the end the startup of the container is defined like this:
ENTRYPOINT ["docker-entrypoint.sh"]
EXPOSE 5432
CMD ["postgres"]
If I understand this right, the argument postgres
is transferred into the docker-entrypoint.sh
so $1
in the script is replaced with postgres
and the script will be executed.
Now my question is if I can define my own Dockerfile based on the postgres image (FROM postgres
) but overwrite the CMD
of the base Dockerfile and accomplish to first execute a command on startup and then execute the docker-entrypoint.sh
with the postgres
argument?
Something like this:
FROM postgres
...
CMD <my-command> && [“postgres”]