I’m on Ubuntu 20.04.5 LTS trying to create a docker container for a mongo database
the command i’m using is:
docker-compose up -d --build
the docker-compose.yml file contains:
version: '2'
services:
ptmdocker-mongodb:
build:
context: ptmdocker-mongodb/
dockerfile: Dockerfile
environment:
- MONGODB_ROOT_PASSWORD=xx
- MONGODB_USERNAME=xx
- MONGODB_PASSWORD=xx
- MONGODB_DATABASE=xx
ports:
- '27017:27017'
volumes:
- /home/administrator/mongo_live_data:/bitnami/mongodb
and the Dockerfile contains:
FROM bitnami/mongodb:latest
VOLUME /backups
USER root
RUN ["apt-get", "update"]
RUN ["apt-get", "install", "-y", "nano"]
EXPOSE 27017
I expect the container to start, and I expect to have an empty database. But after a few seconds the docker container goes down, in the logs I find following error:
mongodb 15:20:35.01
mongodb 15:20:35.01 Welcome to the Bitnami mongodb container
mongodb 15:20:35.01 Subscribe to project updates by watching https://github.com/bitnami/containers
mongodb 15:20:35.01 Submit issues and feature requests at https://github.com/bitnami/containers/issues
mongodb 15:20:35.01
mongodb 15:20:35.02 INFO ==> ** Starting MongoDB setup **
mongodb 15:20:35.03 INFO ==> Validating settings in MONGODB_* env vars...
mongodb 15:20:36.97 INFO ==> Initializing MongoDB...
mongodb 15:20:37.01 INFO ==> Deploying MongoDB from scratch...
mongodb 15:20:37.02 DEBUG ==> Starting MongoDB in background...
Error opening config file: Permission denied
try '/opt/bitnami/mongodb/bin/mongod --help' for more information
I’m mapping the db folder inside the container to a folder on the host:
/home/administrator/mongo_live_data
Maybe there is an issue for permissions on this folder? Any ideas how I can fix this?
2
Answers
More a workaround then a solution, but I installed a new ubuntu instance, this time I used ubuntu 20.04.2 instead of 20.04.5.
After installing docker and docker-compose I could create the mongo docker container with none of the mentioned permissions issues.
(its fixed for me, but I'm still not sure if its because of the ubtuntu version or if I did something wrong on my first ubuntu install...)
From https://hub.docker.com/r/bitnami/mongodb:
To find user with UID 1001: