others-how to solve mongo OCI runtime exec failed: exec failed: unable to start container process unknown problem ?
In this post, I will demonstrate how to solve the following problem when trying to connect mongodb in docker using
docker exec -it command:
[[email protected] mongodb]# docker exec -it d51c4e0b50b2 mongo OCI runtime exec failed: exec failed: unable to start container process: exec: "mongo": executable file not found in $PATH: unknown
[[email protected] mongodb]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d51c4e0b50b2 mongo "docker-entrypoint.s…" 4 minutes ago Up 4 minutes 0.0.0.0:27017->27017/tcp, :::27017->27017/tcp [[email protected] mongodb]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE mongo latest b70536aeb250 2 weeks ago 695MB
The start script of docker mongodb container:
[[email protected] mongodb]# cat start_with_docker.sh docker run -m 100M --memory-swap -1 --name mongodb -p 27017:27017 -d mongo
According to this: https://github.com/docker-library/mongo/issues/558
We should use
mongosh instead of
For mongosh info see: https://docs.mongodb.com/mongodb-shell/
We should use
mongosh as follows:
[[email protected] mongodb]# docker exec -it d51c4e0b50b2 mongosh Current Mongosh Log ID: 636b56ebfa172ca6a7f5fbec Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.6.0 Using MongoDB: 6.0.2 Using Mongosh: 1.6.0 To help improve our products, anonymous usage data is collected and sent to MongoDB periodically (https://www.mongodb.com/legal/privacy-policy). You can opt-out by running the disableTelemetry() command. ------ The server generated these startup warnings when booting 2022-11-09T07:20:03.976+00:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem 2022-11-09T07:20:03.976+00:00: The configured WiredTiger cache size is more than 80% of available RAM. See http://dochub.mongodb.org/core/faq-memory-diagnostics-wt 2022-11-09T07:20:04.842+00:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted 2022-11-09T07:20:04.845+00:00: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. We suggest setting it to 'never' 2022-11-09T07:20:04.845+00:00: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. We suggest setting it to 'never' 2022-11-09T07:20:04.845+00:00: vm.max_map_count is too low ------ ------ Enable MongoDB's free cloud-based monitoring service, which will then receive and display metrics about your deployment (disk utilization, CPU, operation statistics, etc). The monitoring data will be available on a MongoDB website with a unique URL accessible to you and anyone you share the URL with. MongoDB may use this information to make product improvements and to suggest MongoDB products and deployment options to you. To enable free monitoring, run the following command: db.enableFreeMonitoring() To permanently disable this reminder, run the following command: db.disableFreeMonitoring() ------ test> show dbs
In this post, I demonstrated how to connect mongodb in docker using mongosh. That’s it, thanks for your reading.