Reputation: 332
I am testing to see if my commit changes are working for my container. So I create a test file, that just contains text and then I commmit it, then push it to my repository(tagged as latest). Whenever I re-download via docker pull myrepository name. It no longer contains the text file I created as a test.
How can I manipulate it so that the changes I actually make within the container will remain there after I commit, push, and pull back down?
docker pull twsee/atsci405
docker run -it twsee/atsci405 /bin/bash
create file within the main directory of /bin/bash/
exit the container
docker commit 6e667bab0bb967656e81d343d33ffe7dfae35afb868b137ea425e5dbe3533b0c twsee/atsci405:latest
docker push twsee/atsci405:latest
ignore the miss matched container IDs
Upvotes: 1
Views: 2727
Reputation: 332
Due to placing the file within the /bin/bash location it removed it from the image when I pushed it. However I placed several within each directory that followed /bin/bash and each test file remained within the image the next pull I did.
Upvotes: 0
Reputation: 18926
I don't see anything wrong with your flow. I saw a comment above saying you need to commit a 'running' container. That's not correct. See the following:
$ docker run -it alpine:3.3 sh
# touch testfile
# ls
bin home ... testfile ...
# exit
$ docker commit $(docker ps -aql) johnharris85/test-commit:latest
$ docker push johnharris85/test-commit:latest
$ docker rmi johnharris85/test-commit:latest
$ docker run -it johnharris85/test-commit:latest sh
# ls
bin home ... testfile ...
You see different results? Can you post your parent image Dockerfile? Maybe some issue with volumes?
Upvotes: 2