Is it possible to allow the containers running on the same image to share their filesystem?

I am going to explain the question with an example. Suppose that we are running two seperate processes on the same image. One of them creates a file and continues to execute. I need the other process running in a different container to see, inspect, change this file.

Thanks in advance.

  • Creating docker images on successful TeamCity build
  • If I run sudo apt-get update inside docker image and run it as a container, do I still need to sudo apt-get update on the machine too?
  • How does the container use more memory than the limit?
  • Elastic Beanstalk deployment of Docker failing and reverting to old application version
  • How to compile C code that is using kernel function in docker and use pci device in container?
  • always npm install locally from package.json
  • Docker port not overriden
  • Can You Modify the Base Image Directly?
  • Creation of Dockerfile for Android GitLab CI
  • JCoCo Code Coverage inside Docker Image
  • docker-machine:Error with pre-create check: “exit status 126”
  • Docker+Laravel installation
  • 2 Solutions collect form web for “Is it possible to allow the containers running on the same image to share their filesystem?”

    You can use the volumes. The idea is for the container A to create a volume mounted in a specific directory, to perform all operation that are needed to be shared there and for the container B to mount the volume from the container A.

    1) ID=$(docker run -d -v /tmp base /bin/sh -c 'echo hello > /tmp/world')

    2) docker run -volumes-from $ID base cat /tmp/world

    Notice that there is no commit. Both container use the same image.

    Mounting host directories into a container is now possible with the new Bind Mounts feature (currently in master and set to be released shortly with 0.5.0).

    Usage is as follows:

    docker run -t -i -v /host:/container base bash

    This will ensure that the host’s /host directory is mounted to the container’s /container directory, with read-write access.

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