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

350
Vistas
docker python: committed changes in a container but new image does not run

i have a python image called python-example with container_id = c08e4ee85879

Inside exist a python script that prints hello world

file.py

print "HELLO WORLD"

if i run my image: docker run python-example the output HELLO WORLD will be printed on my terminal and then the container will exit.

When i try to enter the container to make a change to the script through vim, exit the container and commit the change to a new image and then try to run the new image, nothing get printed. See steps below

docker run -it python-example bash
vim file.py
#make some changes by adding a new print statement "HELLO WORLD 2"
exit
docker commit c08e4ee85879 python-example2

docker run python-example2 #now nothing gets printed to terminal screen

When i enter the new image then run python file.py, the output gets printed.

docker run -it python-example2 bash
python file.py
"HELLO WORLD"
"HELLO WORLD 2"

Why is this so? Is it not possible for an image to run when changes are commited in bash?

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

0

Solution

Change your commit to:

docker commit --change='CMD ["python", "file.py"]' c08e4ee85879 python-example2

Explanation

When you run:

docker run -it python-example bash

you are changing your default command (which is python file.py to bash).

You can check with docker ps.

CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS               NAMES
c08e4ee85879        python-example        "bash"                   32 seconds ago      Up 30 seconds                           thirsty_hugle

Check dockerfile reference - CMD for more information

With --change='CMD ["python", "file.py"]' you get the desired command back.

over 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