Possible to write a text file (or some other file) in a docker container but access it when container has stopped?
Is it possible to write a text file in a docker container such that I can access the text file when the container is no longer running?
One Solution collect form web for “Possible to write a text file (or some other file) in a docker container but access it when container has stopped?”
Yes, it is, a short example, on my host I create a directory
$ mkdir /tmp/mytest
Then I launch a container bind mounting this directory
$ docker run --rm -it -v /tmp/mytest:/tmp/mytest ubuntu bash
Then I create a file in the container
root@af7f784df77d:/# touch /tmp/mytest/zzzz1234
I quit the container
My file, created inside the container, is still here on my host
$ ls /tmp/mytest
You should read the doc provided by zero323