Does Docker override files?

I have created simple image based on mongo:latest. My Dockerfile is just

FROM mongo:3.3
MAINTAINER developer@encode.cz

Now when I run it by cmd docker run my-mongo mongod I get no /data/db error. But there is clearly RUN mkdir /data/db in mongo base image. Also pure mongo base image works as expected.

  • Multiple dockerfiles in one docker or multiple images from one dockerfile
  • ASP.NET Core 1.0 RC1 Docker with dnu publish
  • Access NFS files from Docker
  • How do I “mount” docker image in another mount?
  • How to create a docker-machine with aws driver with a key-pair that already exists
  • Can't get classpath resource with spring ResourceUtils or DefaultResourceLoader in Docker env
  • Why is this folder not present in my custom image if it is in the base image?

  • Not able to connect to wurstmeister/kafka
  • docker gave me fail error while building code
  • Run RabbitMQ server in Docker
  • Graylog 2.2.0-beta.1 in Docker with UDP input: Unable to load default stream
  • Docker: access to VPN domain from docker
  • Restore deleted container docker
  • One Solution collect form web for “Does Docker override files?”

    I think you have problems in the way you are testing or I don’t understand well your question. I tested the official image:

    docker run -d --name mongo mongo:3.3 mongod
    docker exec -it mongo bash -c 'ls -la /data/db'
    
    total 192
    drwxr-xr-x 4 mongodb mongodb  4096 Oct 28 18:11 .
    drwxr-xr-x 4 root    root     4096 Oct 21 20:47 ..
    -rw-r--r-- 1 mongodb mongodb    46 Oct 28 17:56 WiredTiger
    -rw-r--r-- 1 mongodb mongodb    21 Oct 28 17:56 WiredTiger.lock
    -rw-r--r-- 1 mongodb mongodb   935 Oct 28 18:11 WiredTiger.turtle
    -rw-r--r-- 1 mongodb mongodb 40960 Oct 28 18:11 WiredTiger.wt
    -rw-r--r-- 1 mongodb mongodb  4096 Oct 28 17:56 WiredTigerLAS.wt
    -rw-r--r-- 1 mongodb mongodb 16384 Oct 28 17:57 _mdb_catalog.wt
    -rw-r--r-- 1 mongodb mongodb 16384 Oct 28 17:57 collection-0--3585910680230311914.wt
    -rw-r--r-- 1 mongodb mongodb 16384 Oct 28 17:57 collection-2--3585910680230311914.wt
    drwxr-xr-x 2 mongodb mongodb  4096 Oct 28 18:11 diagnostic.data
    -rw-r--r-- 1 mongodb mongodb 16384 Oct 28 17:57 index-1--3585910680230311914.wt
    -rw-r--r-- 1 mongodb mongodb 16384 Oct 28 17:57 index-3--3585910680230311914.wt
    -rw-r--r-- 1 mongodb mongodb 16384 Oct 28 17:57 index-4--3585910680230311914.wt
    drwxr-xr-x 2 mongodb mongodb  4096 Oct 28 17:56 journal
    -rw-r--r-- 1 mongodb mongodb     2 Oct 28 17:56 mongod.lock
    -rw-r--r-- 1 mongodb mongodb 16384 Oct 28 17:57 sizeStorer.wt
    -rw-r--r-- 1 mongodb mongodb    95 Oct 28 17:56 storage.bson
    

    Then I created a Dockerfile with your two lines and:

    docker build -t my-mongo .
    docker run -d --name my-mongo my-mongo mongod
    docker exec -it my-mongo bash -c 'ls -la /data/db'
    
    total 192
    drwxr-xr-x 4 mongodb mongodb  4096 Oct 28 18:12 .
    drwxr-xr-x 4 root    root     4096 Oct 21 20:47 ..
    -rw-r--r-- 1 mongodb mongodb    46 Oct 28 18:06 WiredTiger
    -rw-r--r-- 1 mongodb mongodb    21 Oct 28 18:06 WiredTiger.lock
    -rw-r--r-- 1 mongodb mongodb   932 Oct 28 18:12 WiredTiger.turtle
    -rw-r--r-- 1 mongodb mongodb 40960 Oct 28 18:12 WiredTiger.wt
    -rw-r--r-- 1 mongodb mongodb  4096 Oct 28 18:06 WiredTigerLAS.wt
    -rw-r--r-- 1 mongodb mongodb 16384 Oct 28 18:07 _mdb_catalog.wt
    -rw-r--r-- 1 mongodb mongodb 16384 Oct 28 18:07 collection-0-683121925029568227.wt
    -rw-r--r-- 1 mongodb mongodb 16384 Oct 28 18:07 collection-2-683121925029568227.wt
    drwxr-xr-x 2 mongodb mongodb  4096 Oct 28 18:13 diagnostic.data
    -rw-r--r-- 1 mongodb mongodb 16384 Oct 28 18:07 index-1-683121925029568227.wt
    -rw-r--r-- 1 mongodb mongodb 16384 Oct 28 18:07 index-3-683121925029568227.wt
    -rw-r--r-- 1 mongodb mongodb 16384 Oct 28 18:07 index-4-683121925029568227.wt
    drwxr-xr-x 2 mongodb mongodb  4096 Oct 28 18:06 journal
    -rw-r--r-- 1 mongodb mongodb     2 Oct 28 18:06 mongod.lock
    -rw-r--r-- 1 mongodb mongodb 16384 Oct 28 18:07 sizeStorer.wt
    -rw-r--r-- 1 mongodb mongodb    95 Oct 28 18:06 storage.bson
    

    Be aware, the /data/db directory is declared as a volume. If you are having problems withn that, restart the docker daemon and check your available disk space df -h

    Regards

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