Consider:
docker run -it centos /bin/bash
I pressed Ctrl+D to exit it.
I want to continue to run this container, but I found I can't.
The only method is
docker commit `docker ps -q -l` my_image docker run -it my_image /bin/bash
Am I right? Is there a better method? (I'm using docker 0.8.0.)
Enter the docker start command with the Container ID in the command line to resume the Container. Note: This preserves environment variables set during the initial docker run statement.
To restart an existing container, we'll use the start command with the -a flag to attach to it and the -i flag to make it interactive, followed by either the container ID or name. Be sure to substitute the ID of your container in the command below: docker start -ai 11cc47339ee1.
When this happens, the program will stop, and the container will exit. The container has been stopped using docker stop : You can manually stop a container using the docker stop command. The Docker daemon has restarted, and it terminated and restarted the container: Docker can restart containers if you need it to.
You can restart an existing container after it exited and your changes are still there.
docker start `docker ps -q -l` # restart it in the background docker attach `docker ps -q -l` # reattach the terminal & stdin
docker start -a -i `docker ps -q -l`
Explanation:
docker start
start a container (requires name or ID)-a
attach to container-i
interactive modedocker ps
List containers -q
list only container IDs-l
list only last created container
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With