0 votes
1 view
in DevOps and Agile by (2.3k points)
I need to use a different command than the default command to start my container. This is because on using the default command it crashes, hence i can't start my container and then make use of 'docker exec' to get into the container.

In a nutshell, I want to be able to start a shell where I can check out all the contents of my container. ( my container was created with the -it option )

1 Answer

0 votes
by (6.7k points)

 First, Locate your stopped container ID using this command:

$ sudo docker ps -a

  Then, commit your stopped container using this command:

$ sudo docker commit $CONTAINER_ID user/test_image

 Now, start your stopped container with a completely different entery point, like so:

 $ sudo docker run -ti --entrypoint=sh user/test_image

You can read more about ENTRYPOINT here: https://docs.docker.com/engine/reference/run/#/entrypoint-default-command-to-execute-at-runtime

Now keep in mind in the above method you are only going to have access for a quick look, a lot of funcitonalities are not inherited ( eg. Env variables, network conf, volumes) , you will have to specify them as arguments separately.
 


If you are interested in knowing how to work with containers and images in a more detailed manner check out docker training course.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...