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”]
You can create you own my-entrypoint.sh
$ cat my-entrypoint.sh
#!/bin/bash
#do what you need here e.g. <my-command>
#next command will run postgres entrypoint will all params
docker-entrypoint.sh "$@"
And your docker file will look as follows
FROM postgres
# your stuff
ENTRYPOINT ["my-entrypoint.sh"]
EXPOSE 5432
CMD ["postgres"]
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments