Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

289
Vistas
confused with CMD and ENTRYPOINT in dockerfile

I have known that in the dockerfile, when ENTRYPOINT and CMD are both provided, the values in CMD will be as default parameter of ENTRYPOINT, then when running a container with additional parameter, the additional parameter will replace the values of CMD in dockerfile.

but when I see the dockerfile of mongodb, I'm confused, the entrypoint and cmd part of its dockerfile:

ENTRYPOINT ["docker-entrypoint.sh"]

EXPOSE 27017
CMD ["mongod"]

I know when I run docker run mongo:latest this will be docker-entrypoint.sh mongod, but when I run docker run mongo:latest --auth, why could it run correctly? Won't it be docker-entrypoint.sh --auth? since the --auth will replace mongod, so why I run docker run mongo --auth but it works fine?

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The mongod Dockerfile references docker-entrypoint.sh.
That script docker-entrypoint.sh starts by testing if the first parameter begins with '-' (as in '--auth'):

if [ "${1:0:1}" = '-' ]; then
    set -- mongod "$@"
fi

So the arguments become mongod --auth, not just --auth.

Meaning:

  • if you have to pass any argument after mongod, you don't have to type mongod first when using docker run: it will be added for you in docker-entrypoint.sh
  • if you don't have any argument to pass after mongod, you don't have to type mongod either: CMD will provide it for you to the ENTRYPOINT docker-entrypoint.sh.
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda