I knew that in the docker file, when ENTRYPOINT and CMD are provided, the values ββin the CMD will be the default parameter ENTRYPOINT, then when you start the container with the additional parameter, the additional parameter will replace the CMD values ββin the dockerfile.
but when I see the mongodb docker file, I am confused by the entry point and cmd part of its docker file:
ENTRYPOINT ["docker-entrypoint.sh"]
EXPOSE 27017
CMD ["mongod"]
I know when I started docker run mongo:latest, it will be docker-entrypoint.sh mongod, but when I started docker run mongo:latest --auth, why could it work correctly? Won't it be docker-entrypoint.sh --auth? because it --authreplaces mongod, so why am I running docker run mongo --auth, but it works fine?
source
share