Problem:
You are trying to run a docker bitnami/mariadb
container but when you try to start it up, you see an error message like
mariadb_1 | mkdir: cannot create directory '/bitnami/mariadb': Permission denied
Solution:
bitnami
containers mostly are non-root-containers, hence you need to adjust the permissions for the data directory mapped onto the host.
First, find out what directory your /bitnami
is mapped to on the host. For example, for
services: mariadb: image: 'bitnami/mariadb:latest' environment: - ALLOW_EMPTY_PASSWORD=yes volumes: - '/var/lib/my_docker/mariadb_data:/bitnami'
it is mapped to /var/lib/my_docker/mariadb_data
.
Now chown
this directory to 1001:1001
since the image is using UID 1001
as the user running the command:
sudo chown -R 1001:1001 [directory]
for example
sudo chown -R 1001:1001 /var/lib/my_docker/mariadb_data