mongo: Error saving history file: FileOpenFailed: Unable to open() file /home/mongodb/.dbshell: Unknown error
Dockerfile
FROM mongo
ADD ./mongo-init.sh /docker-entrypoint-initdb.d/
mongodb_1 | about to fork child process, waiting until server is ready for connections.
mongodb_1 | forked process: 29
mongodb_1 | 2019-01-15T21:20:47.367+0000 I CONTROL [main] ***** SERVER RESTARTED *****
mongodb_1 | 2019-01-15T21:20:47.370+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
mongodb_1 | 2019-01-15T21:20:47.374+0000 I CONTROL [initandlisten] MongoDB starting : pid=29 port=27017 dbpath=/data/db 64-bit host=343629fa23cd
mongodb_1 | 2019-01-15T21:20:47.374+0000 I CONTROL [initandlisten] db version v4.0.5
mongodb_1 | 2019-01-15T21:20:47.374+0000 I CONTROL [initandlisten] git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
mongodb_1 | 2019-01-15T21:20:47.374+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
mongodb_1 | 2019-01-15T21:20:47.374+0000 I CONTROL [initandlisten] allocator: tcmalloc
mongodb_1 | 2019-01-15T21:20:47.374+0000 I CONTROL [initandlisten] modules: none
mongodb_1 | 2019-01-15T21:20:47.374+0000 I CONTROL [initandlisten] build environment:
mongodb_1 | 2019-01-15T21:20:47.374+0000 I CONTROL [initandlisten] distmod: ubuntu1604
mongodb_1 | 2019-01-15T21:20:47.374+0000 I CONTROL [initandlisten] distarch: x86_64
mongodb_1 | 2019-01-15T21:20:47.374+0000 I CONTROL [initandlisten] target_arch: x86_64
mongodb_1 | 2019-01-15T21:20:47.374+0000 I CONTROL [initandlisten] options: { net: { bindIp: "127.0.0.1", port: 27017, ssl: { mode: "disabled" } }, processManagement: { fork: true, pidFilePath: "/tmp/docker-entrypoint-temp-mongod.pid" }, systemLog: { destination: "file", logAppend: true, path: "/proc/1/fd/1" } }
mongodb_1 | 2019-01-15T21:20:47.374+0000 I STORAGE [initandlisten]
mongodb_1 | 2019-01-15T21:20:47.374+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
mongodb_1 | 2019-01-15T21:20:47.374+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
mongodb_1 | 2019-01-15T21:20:47.375+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=487M,session_max=20000,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),statistics_log=(wait=0),verbose=(recovery_progress),
mongodb_1 | 2019-01-15T21:20:47.866+0000 I STORAGE [initandlisten] WiredTiger message [1547587247:866155][29:0x7eff7bb21a40], txn-recover: Set global recovery timestamp: 0
mongodb_1 | 2019-01-15T21:20:47.873+0000 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
mongodb_1 | 2019-01-15T21:20:47.883+0000 I CONTROL [initandlisten]
mongodb_1 | 2019-01-15T21:20:47.883+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
mongodb_1 | 2019-01-15T21:20:47.883+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
mongodb_1 | 2019-01-15T21:20:47.883+0000 I CONTROL [initandlisten]
mongodb_1 | 2019-01-15T21:20:47.883+0000 I STORAGE [initandlisten] createCollection: admin.system.version with provided UUID: 6019a1c5-fc8c-45ed-9355-5677a9ed6c47
mongodb_1 | 2019-01-15T21:20:47.892+0000 I COMMAND [initandlisten] setting featureCompatibilityVersion to 4.0
mongodb_1 | 2019-01-15T21:20:47.897+0000 I STORAGE [initandlisten] createCollection: local.startup_log with generated UUID: bc5c6df0-c572-4cbe-815c-daebc8c7f596
mongodb_1 | 2019-01-15T21:20:47.909+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
mongodb_1 | 2019-01-15T21:20:47.911+0000 I NETWORK [initandlisten] waiting for connections on port 27017
mongodb_1 | 2019-01-15T21:20:47.911+0000 I STORAGE [LogicalSessionCacheRefresh] createCollection: config.system.sessions with generated UUID: b7cba875-b5b1-4633-9d4e-944a52b3c84a
mongodb_1 | child process started successfully, parent exiting
mongodb_1 | 2019-01-15T21:20:47.925+0000 I INDEX [LogicalSessionCacheRefresh] build index on: config.system.sessions properties: { v: 2, key: { lastUse: 1 }, name: "lsidTTLIndex", ns: "config.system.sessions", expireAfterSeconds: 1800 }
mongodb_1 | 2019-01-15T21:20:47.925+0000 I INDEX [LogicalSessionCacheRefresh] building index using bulk method; build may temporarily use up to 500 megabytes of RAM
mongodb_1 | 2019-01-15T21:20:47.926+0000 I INDEX [LogicalSessionCacheRefresh] build index done. scanned 0 total records. 0 secs
mongodb_1 | 2019-01-15T21:20:47.969+0000 I NETWORK [listener] connection accepted from 127.0.0.1:36626 #1 (1 connection now open)
mongodb_1 | 2019-01-15T21:20:47.969+0000 I NETWORK [conn1] received client metadata from 127.0.0.1:36626 conn1: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.5" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
mongodb_1 | 2019-01-15T21:20:47.972+0000 I NETWORK [conn1] end connection 127.0.0.1:36626 (0 connections now open)
mongodb_1 | 2019-01-15T21:20:48.032+0000 I NETWORK [listener] connection accepted from 127.0.0.1:36628 #2 (1 connection now open)
mongodb_1 | 2019-01-15T21:20:48.032+0000 I NETWORK [conn2] received client metadata from 127.0.0.1:36628 conn2: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "4.0.5" }, os: { type: "Linux", name: "Ubuntu", architecture: "x86_64", version: "16.04" } }
mongodb_1 | 2019-01-15T21:20:48.065+0000 I STORAGE [conn2] createCollection: admin.system.users with generated UUID: 0ec16545-de93-480f-ad22-184f838e30b6
mongodb_1 | Successfully added user: {
mongodb_1 | "user" : "root",
mongodb_1 | "roles" : [
mongodb_1 | {
mongodb_1 | "role" : "root",
mongodb_1 | "db" : "admin"
mongodb_1 | }
mongodb_1 | ]
mongodb_1 | }
mongodb_1 | 2019-01-15T21:20:48.084+0000 E - [main] Error saving history file: FileOpenFailed: Unable to open() file /home/mongodb/.dbshell: Unknown error
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 38
- Comments: 30 (10 by maintainers)
Commits related to this issue
- Work around need to write monogodb sh history in MC-database. Removes an error message. See: https://github.com/docker-library/mongo/issues/323 — committed to BenedictAdamson/MC by BenedictAdamson 4 years ago
- Adding -m option to useradd Fixing : https://github.com/docker-library/mongo/issues/323 and https://github.com/docker-library/mongo/issues/390. Ref.: https://linux.die.net/man/8/useradd — committed to romintomasetti/mongo by romintomasetti 3 years ago
- Add docker-compose for app image and db image Replace all password notions by environmental variables NOTE: Should not commit ./home directory. Used as this issue workaround: https://github.com/docke... — committed to pyatizbyantsevia/IMET-bot by aaletov 2 years ago
Dealing with exactly the same error. Mongo image v 4.0.6. First “clean” initial run on container with variables
MONGO_INITDB_ROOT_USERNAME, MONGO_INITDB_ROOT_USERNAME
successfully creates admin user. But after stopping container and starting it again error comes up:Manually hacking the container and removing env. varibles
MONGO_INITDB_ROOT_USERNAME, MONGO_INITDB_ROOT_USERNAME
from it resolves the issue. So, it seems, like mongo image tries to create user fromMONGO_INITDB_ROOT_USERNAME
even if DB was already initialized. This is very confusing, especially considering the docs on dockerhub which say:How to set up first super user in a proper way, so that not to break cluster after stop?
UPD: issue happens when running mongod as configsvr instance;
Hi, all,
I have met this problem today. I used the docker image tag:
4.0.9
.Problem
I used
docker exec -it container-mongo /bin/bash
to go inside, and find:There is no home folder for the user of
mongodb
.Yes, in the error message:
The folder
/home/mongodb
does not exist.Solution
Then my solution is:
\home\mongodb
Remind: don’t use user and group name in your host for the owner assign - instead use the id of user and group.
You can get mongodb user and group id used in the docker image:
After these steps, the error message is gone, and .dbshell shows up in the folder which owner is
999:999
.One line command:
Why
I check the dockerfile, and find the creation of the user
mongodb
is missing-m
arugment:@wglambert I create two secrets for the mongo container
MONGO_INITDB_ROOT_USERNAME, MONGO_INITDB_ROOT_PASSWORD
. The container automatically creates the root user. The error message showed up between adding the root user and execution of the custom init script.From what I’ve seen, the error doesn’t prevent anything from working, so it’s really more of a warning – is someone else seeing behavior different from that?
Is everybody using the manual folder workaround ? Should we proceed with a PR to add the -m option to the dockerfile ?
As of today, I still have this issue with the latest image of mongo.
For people using Docker Compose, here is what I did.
1. Create the folder
./home/mongodb
on your local filesystem.2. Create the file
./home/mongodb/.dbshell
3. Change the permission of the folder to match the one used in the Dockerfile.
4. Add a volume to your Docker Compose service (mine is called
barret
for context).For me this error stopped mongo from creating the root user specified by the env variables. The mentioned workaround (mapping /home/mongodb) worked and after cleaning the whole mongo directory and doing a fresh initialize everything works as expected!
I tried all the above and nothing worked for me. I switched my init file from sh to js and everything is fine now. The problem now is that I have to figure out how to use env variables in the js file.
Correct… Sorry.
It seems I was having another problem related with the base64 of the secret inserting a \n at the end of the pasword (https://github.com/docker-library/mongo/issues/346).
thanks, works! but don’t need to create this path
/home/mongodb
, can be other, likes./data
. andchown -R $USER ./data
+1