Reputation: 401
I have a docker container running and would like to know if I can save its state without commiting it. For example: 1. Start container 2. Create a new file inside it 3. Exit container 4. Start container
Can the file still exist in this container without running docker commit before exiting.
Upvotes: 1
Views: 1302
Reputation: 39387
Docker's stopped
, exited
Containers, Maintain files and changes in container's writable AUFS layer
. Please note this layer will be removed when the container is removed.
POC:
sudo docker run -it --name test debian:jessie /bin/bash
root@3d01feb251bd:/# touch farhad
root@3d01feb251bd:/# exit
sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3d01feb251bd debian:jessie "/bin/bash" 16 seconds ago Exited (0) 7 seconds ago test
sudo docker start test
sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3d01feb251bd debian:jessie "/bin/bash" 31 seconds ago Up 8 seconds test
sudo docker exec -it test /bin/bash
root@3d01feb251bd:/# ls
bin boot dev etc farhad home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
As you can see the file I touched before exiting the container is still there.
Upvotes: 3