Dockerizing mongodb with local data

  docker, docker-compose, mongodb

I’m trying to create a docker container with docker-compose with persistent data on local drive(with relative path), but no matter what I try I can’t get it to work. Without declaring the volumes it works just fine

version: '3.7'
services:
  mongo:
    container_name: mongo
    hostname: mongo
    image: mongo
    restart: always
    volumes:
      - ./data/db:/data/db
    ports:
      - "27017:27017"
    networks:
      - resolute
networks:
  resolute:
    name: resolute

What the heck am I doing wrong, please?

Here’s a log I’m getting:

Creating mongo … done
Attaching to mongo mongo |
{"t":{"$date":"2021-02-02T13:11:46.012+00:00"},"s":"I",
"c":"CONTROL", "id":23285, "ctx":"main","msg":"Automatically
disabling TLS 1.0, to force-enable TLS 1.0 specify
–sslDisabledProtocols ‘none’"} mongo | {"t":{"$date":"2021-02-02T13:11:46.019+00:00"},"s":"W", "c":"ASIO",
"id":22601, "ctx":"main","msg":"No TransportLayer configured during
NetworkInterface startup"} mongo |
{"t":{"$date":"2021-02-02T13:11:46.019+00:00"},"s":"I",
"c":"NETWORK", "id":4648601, "ctx":"main","msg":"Implicit TCP
FastOpen unavailable. If TCP FastOpen is required, set
tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
mongo | {"t":{"$date":"2021-02-02T13:11:46.020+00:00"},"s":"I",
"c":"STORAGE", "id":4615611, "ctx":"initandlisten","msg":"MongoDB
starting","attr":{"pid":1,"port":27017,"dbPath":"/data/db","architecture":"64-bit","host":"mongo"}}
mongo | {"t":{"$date":"2021-02-02T13:11:46.020+00:00"},"s":"I",
"c":"CONTROL", "id":23403, "ctx":"initandlisten","msg":"Build
Info","attr":{"buildInfo":{"version":"4.4.3","gitVersion":"913d6b62acfbb344dde1b116f4161360acd8fd13","openSSLVersion":"OpenSSL
1.1.1 11 Sep 2018","modules":[],"allocator":"tcmalloc","environment":{"distmod":"ubuntu1804","distarch":"x86_64","target_arch":"x86_64"}}}}
mongo | {"t":{"$date":"2021-02-02T13:11:46.020+00:00"},"s":"I",
"c":"CONTROL", "id":51765, "ctx":"initandlisten","msg":"Operating
System","attr":{"os":{"name":"Ubuntu","version":"18.04"}}} mongo |
{"t":{"$date":"2021-02-02T13:11:46.020+00:00"},"s":"I",
"c":"CONTROL", "id":21951, "ctx":"initandlisten","msg":"Options set
by command line","attr":{"options":{"net":{"bindIp":""}}}} mongo |
{"t":{"$date":"2021-02-02T13:11:46.039+00:00"},"s":"I",
"c":"STORAGE", "id":22315, "ctx":"initandlisten","msg":"Opening
WiredTiger","attr":{"config":"create,cache_size=483M,session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress,compact_progress],"}}
mongo | {"t":{"$date":"2021-02-02T13:11:46.848+00:00"},"s":"E",
"c":"STORAGE", "id":22435, "ctx":"initandlisten","msg":"WiredTiger
error","attr":{"error":17,"message":"[1612271506:848454][1:0x7f2e57da9ac0],
connection: __posix_open_file, 808: /data/db/WiredTiger.wt:
handle-open: open: File exists"}} mongo |
{"t":{"$date":"2021-02-02T13:11:46.852+00:00"},"s":"I",
"c":"STORAGE", "id":22430, "ctx":"initandlisten","msg":"WiredTiger
message","attr":{"message":"unexpected file WiredTiger.wt found,
renamed to WiredTiger.wt.45"}} mongo |
{"t":{"$date":"2021-02-02T13:11:46.855+00:00"},"s":"E",
"c":"STORAGE", "id":22435, "ctx":"initandlisten","msg":"WiredTiger
error","attr":{"error":1,"message":"[1612271506:855854][1:0x7f2e57da9ac0],
connection: __posix_open_file, 808: /data/db/WiredTiger.wt:
handle-open: open: Operation not permitted"}} mongo |
{"t":{"$date":"2021-02-02T13:11:46.890+00:00"},"s":"E",
"c":"STORAGE", "id":22435, "ctx":"initandlisten","msg":"WiredTiger
error","attr":{"error":17,"message":"[1612271506:890013][1:0x7f2e57da9ac0],
connection: __posix_open_file, 808: /data/db/WiredTiger.wt:
handle-open: open: File exists"}} mongo |
{"t":{"$date":"2021-02-02T13:11:46.899+00:00"},"s":"I",
"c":"STORAGE", "id":22430, "ctx":"initandlisten","msg":"WiredTiger
message","attr":{"message":"unexpected file WiredTiger.wt found,
renamed to WiredTiger.wt.46"}} mongo |
{"t":{"$date":"2021-02-02T13:11:46.904+00:00"},"s":"E",
"c":"STORAGE", "id":22435, "ctx":"initandlisten","msg":"WiredTiger
error","attr":{"error":1,"message":"[1612271506:904063][1:0x7f2e57da9ac0],
connection: __posix_open_file, 808: /data/db/WiredTiger.wt:
handle-open: open: Operation not permitted"}} mongo |
{"t":{"$date":"2021-02-02T13:11:46.948+00:00"},"s":"E",
"c":"STORAGE", "id":22435, "ctx":"initandlisten","msg":"WiredTiger
error","attr":{"error":17,"message":"[1612271506:948645][1:0x7f2e57da9ac0],
connection: __posix_open_file, 808: /data/db/WiredTiger.wt:
handle-open: open: File exists"}} mongo |
{"t":{"$date":"2021-02-02T13:11:46.959+00:00"},"s":"I",
"c":"STORAGE", "id":22430, "ctx":"initandlisten","msg":"WiredTiger
message","attr":{"message":"unexpected file WiredTiger.wt found,
renamed to WiredTiger.wt.47"}} mongo |
{"t":{"$date":"2021-02-02T13:11:46.968+00:00"},"s":"E",
"c":"STORAGE", "id":22435, "ctx":"initandlisten","msg":"WiredTiger
error","attr":{"error":1,"message":"[1612271506:967967][1:0x7f2e57da9ac0],
connection: __posix_open_file, 808: /data/db/WiredTiger.wt:
handle-open: open: Operation not permitted"}} mongo |
{"t":{"$date":"2021-02-02T13:11:46.972+00:00"},"s":"W",
"c":"STORAGE", "id":22347, "ctx":"initandlisten","msg":"Failed to
start up WiredTiger under any compatibility version. This may be due
to an unsupported upgrade or downgrade."} mongo |
{"t":{"$date":"2021-02-02T13:11:46.973+00:00"},"s":"F",
"c":"STORAGE", "id":28595,
"ctx":"initandlisten","msg":"Terminating.","attr":{"reason":"1:
Operation not permitted"}} mongo |
{"t":{"$date":"2021-02-02T13:11:46.973+00:00"},"s":"F", "c":"-",
"id":23091, "ctx":"initandlisten","msg":"Fatal
assertion","attr":{"msgid":28595,"file":"src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp","line":1123}}
mongo | {"t":{"$date":"2021-02-02T13:11:46.973+00:00"},"s":"F",
"c":"-", "id":23092,
"ctx":"initandlisten","msg":"nn
**aborting after fassert()
failurenn"}

Source: Docker Questions

LEAVE A COMMENT