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.

  • What is the working directory of a Docker Golang application?
  • How do we set the the RAM and disk space for a docker container?
  • Docker container without isolation? For host system information collecting
  • SSH to Docker: Permission denied (publickey)
  • Vagrant unable to connect to docker through ssh
  • Is it possible to super scale a dockerised selenium grid?
  • Why is this folder not present in my custom image if it is in the base image?

  • Remote Debugging with XDebug from inside a Docker Container does not work
  • Why Jenkins not stored data?
  • docker Unable to connect to archive.ubuntu.com:http: [IP: 209.6.3.210 80]
  • Unable to form Hazelcast cluser on a multinode docker environment
  • How to setup unit test in Docker for nodejs application?
  • Jenkins deployment to docker swarm by using Ansible
  • 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.