I have the following system:
Fedora 41
podman-compose version 1.3.0
podman version 5.3.2
and I followed this tutorial for rootless podman. basically pasta for rootless networking, and the /etc/subuid and /etc/subgid configuration.
Then I tried the following steps:
# creating directories
mkdir -p ~/podman-volumes/mongo/data ~/podman-volumes/mongo/logs
mkdir -p ~/podman-volumes/mongo/config/
# create mongod.conf w/ contents
vim ~/podman-volumes/mongo/config/mongod.conf
storage:
dbPath: /data/db
systemLog:
destination: file
path: /var/log/mongodb/mongo.log
logAppend: true
net:
bindIp: 0.0.0.0
port: 27017
# create directory w/ compose file
mkdir -p ~/mongodb/
vim ~/mongodb/docker-compose.yml
services:
mongodb:
image: mongo:latest
container_name: mongodb
restart: always
ports:
- "27017:27017"
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: secret
volumes:
- ~/podman-volumes/mongo/data:/data/db
- ~/podman-volumes/mongo/logs:/var/log/mongodb
- ~/podman-volumes/mongo/config/mongod.conf:/etc/mongod.conf:ro
command: ["--config", "/etc/mongod.conf"]
All directories and files have my current user as owner.
when I first executed podman-compose up I get the error chown: changing ownership of '/data/db': Permission denied - I then somewhere found that mongodb is running with user ID 999 inside the container, and I could probably fix it with the following command:
podman unshare chown -R 999:999 ~/podman-volumes/mongo/data
This solved the one mentioned problem, but I still get find: '/data/db': Permission denied. Somehow this should have been solved by the podman unshare command, but it didn't.
I tried adding user: "1000:1000" (which is my current user ID) to the compose file, still no luck.
my question(s):
- what do I need to do to get MongoDB running, with my custom configuration?
- how can I determine which user ID is used in a container ?
Just a note: I'm having the same problems with lots of other images (e.g. Elastic, Logstash) when I provide a custom configuration file and I want the logs to be stored locally, I always get permission denied
~in any folder specification. It's the current user home folder and may change and looks like you refer to wrong user. Better use absolute path names.