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?

  • How to store my docker registry in the file system
  • Docker - running commands from all containers
  • How do you deliver your application using the concept of containers (Docker containers)
  • How to connect to a remote Docker container via JMX
  • Kubernetes for a Development Environment
  • Docker and grunt-based workflow automation
  • Can't get docker running on Cloud9 IDE
  • AWS container service: set max_map_count
  • Docker images on different docker versions
  • Docker in Vagrant issuing : Warning: Connection refused. Retrying
  • Kubernetes can not get its own cluster IP
  • Docker DNS getaddrinfo ENOTFOUND
  • 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

    # exit

    My file, created inside the container, is still here on my host

    $ ls /tmp/mytest
    zzzz1234

    You should read the doc provided by zero323

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.