docker cannot create directory - docker

this is my docker compose yml file
version: '2'
services:
mariadb:
image: 'bitnami/mariadb:latest'
restart: unless-stopped
ports:
- 3306:3306
environment:
- MARIADB_ROOT_USER=root
- MARIADB_ROOT_PASSWORD=root
- MARIADB_DATABASE=DB
- MARIADB_USER=user
- MARIADB_PASSWORD=pass!
- MARIADB_CHARACTER_SET=utf8
- MARIADB_COLLATE=utf8_general_ci
volumes:
- /Users/joachim/project/docker/mariadb/:/bitnami/mariadb
Im getting this error
mkdir: cannot create directory '/bitnami/mariadb/data': Permission denied
How might i solve this?

Since you're using Windows, I assume, that you're using MinGW as your bash environment (your path is UNIX-line path). To access your drive C you need to add /c at the beginning of your path.
So, your mount path will be equal to this path
/c/Users/joachim/project/docker/mariadb/

Related

docker compose I want use my local directory C:/html for /var/www/html

Hello I want to publish the "index.php" from the local folder "C:\html\index.php" with docker-compose.yml
in localhost I get the typical apache html "It works". But I do not get the content of my local folder. What I am doing wrong?
here is my docker-compose file:
version: "3"
services:
# --- MySQL 5.7
#
mysql:
container_name: "dstack-mysql"
image: bitnami/mysql:5.7
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_USER=admin
- MYSQL_PASSWORD=root
ports:
- '3306:3306'
php:
container_name: "dstack-php"
image: bitnami/php-fpm:8.1
# --- Apache 2.4
#
apache:
container_name: "dstack-apache"
image: bitnami/apache:2.4
ports:
- '80:8080'
- '443:8443'
depends_on:
- php
volumes:
- C:/html:/var/www/html
phpmyadmin:
container_name: "dstack-phpmyadmin"
image: bitnami/phpmyadmin:latest
depends_on:
- mysql
ports:
- '81:8080'
- '8143:8443'
environment:
- DATABASE_HOST=host.docker.internal
volumes:
dstack-mysql:
driver: local
Update:
volumes:
- ./html:/var/www/html
Doesn't works.
I want to have a web development docker environment where I edit in the folder C:\html\index_hello.html in my computer and I will see the changes in the browser localhost:8080, the changes I did. My expectation is that I write in the browser http://localhost:8080/index_hello.html. Did I something wrong? shall I edit other files e.g. apache.conf?
I would suggest avoiding hardcoding directories and using relative directories.
If you place your docker-compose into your C:/html folder and then change you volume to read:
volumes:
- .:/var/www/html
if you run the following:
cd C:/html
docker-compose up -d
you are telling docker-compose to use . meaning the current directory.
if you put the docker-compose.yml in the C:/ directory you can run change the volume to:
volumes:
- ./html:/var/www/html
then the docker compose command should remain the same.

How to use custom ini file for Grafana with Docker?

I have like this container in my docker-compose file:
grafana:
image: grafana/grafana
ports:
- '3000:3000'
environment:
- GF_PATHS_CONFIG="./grafana/etc/grafana.ini"
- GF_INSTALL_PLUGINS=grafana-piechart-panel,grafana-worldmap-panel,vertamedia-clickhouse-datasource,vertamedia-chtable
Inside grafana.ini I tried change default admin login and password like this:
[security]
admin_user = user
admin_password = 1234
But it is doesn’t work for me. How I can use my custom .ini file with Grafana in Docker correctly?
Grafana version: Grafana v7.4.3 (010f20c1c8)
So, there are 2 things that come to my mind when I saw your compose file.
Do I need to change the config path?
Where is my custom .ini file?
When running a container with an official image (as grafana/grafana), we cannot change the config without feeding it from the outside. So you should specify it in your compose file as a "volume".
version: "3.9"
services:
grafana:
image: grafana/grafana
ports:
- '3000:3000'
environment:
- GF_INSTALL_PLUGINS=grafana-piechart-panel,grafana-worldmap-panel,vertamedia-clickhouse-datasource
volumes:
- "./grafana.ini:/etc/grafana/grafana.ini"
- "grafana-storage:/var/lib/grafana"
volumes:
grafana-storage:
Also, you have to put your grafana.ini file in the same directory for this compose file to run:
[security]
admin_user = user
admin_password = 1234
It should work when you run docker-compose up.
P.S. I removed vertamedia-chtable plugin because it cannot be found by the installer and grafana raised an error.

docker-compose couchdb missing files

I'm trying to run couchdb via docker-compose:
version: '3'
services:
couchdb:
image: "couchdb:2"
restart: always
ports:
- 5984:5984
volumes:
- /data/couchdb:/opt/couchdb/etc/
- /data/couchdb_config:/opt/couchdb/etc/local.d
environment:
- COUCHDB_USER=myuser
- COUCHDB_PASSWORD=mypassword
the container crashes during start:
Failed to open arguments file "/opt/couchdb/bin/../etc/vm.args": No such file or directory
Usage: erl......
grep: /opt/couchdb/etc/default.d/*.ini: No such file or directory
In data/couchdb_config I am providing a standard local.ini file. When I don't do that, couchdb complains that it's missing as well.
What's the problem here?
you need to set points before data path .Docker-comose need to know that data is in the same path as the docker-compose file
version: '3'
services:
couchdb:
image: "couchdb:2"
restart: always
ports:
- 5984:5984
volumes:
- ./data/couchdb:/opt/couchdb/etc/
- ./data/couchdb_config:/opt/couchdb/etc/local.d
environment:
- COUCHDB_USER=myuser
- COUCHDB_PASSWORD=mypassword
The error was the mapping of a wrong volume:
my_couchdb_data:/opt/couchdb/etc
should be
my_couchdb_data:/opt/couchdb/data

docker volume create - set permissions

I'm running this on debian 9
I'm using sudo docker volume create db to create a volume I'm using in my docker-compose.yml. But I still get the error db_1_d89b59353579 | mkdir: cannot create directory '/var/lib/mysql': Permission denied.
How can I set permissions for the user using that volume. And how to get the user?
Docker-Compose:
version: '2'
volumes:
nextcloud:
db:
services:
db:
image: mariadb
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
restart: always
volumes:
- db:/var/lib/mysql:z
environment:
- MYSQL_ROOT_PASSWORD=***
- MYSQL_PASSWORD=***
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
app:
image: nextcloud
ports:
- 8080:80
links:
- db
volumes:
- nextcloud:/var/www/html
restart: always
I got an install.sh file where I run:
...
sudo docker volume create db
sudo docker-compose build
docker-compose up -d
Try to first change the mounts to local folders and see if that fixes your issue:
version: '2'
volumes:
nextcloud:
db:
services:
db:
...
volumes:
- ./db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=***
- MYSQL_PASSWORD=***
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
app:
...
volumes:
- ./nextcloud:/var/www/html
restart: always
If that does then check that the volumes are correctly removed by docker-compose down. Run docker volume ls. If they still persist then remove them by hand and rerun your containers with the volumes.
Regarding the difference between mounting to a volume (db:/var/lib/mysql) and mounting to a host path (./db:/var/lib/mysql):
In the first case it is a volume managed by Docker. It is meant for persistence but getting to the files is a bit more tricky. In the second case it is a path on the host and it makes it a lot easier to retrieve persisted files. I recommend to run "docker-compose config" for both situations and see the difference in how docker-compose internally transforms the statement.

unable to override volume mount with docker-compose.override

I am trying to spin up a local version of a web app on my Mac and I need to tell docker-compose not to attempt to mount certain volumes. I am using a docker-compose.override.yml file, but what I am doing is apparently not overriding anything.
Here's the relevant part of my docker-compose.yml:
version: '3'
services:
web:
volumes:
- user-data:/usr/src/app/flask_brain_db/static/images/data
- /etc/letsencrypt:/etc/letsencrypt
nginx:
volumes:
- ./web/flask_brain_db/static:/usr/src/app/flask_brain_db/static
- user-data:/usr/src/app/flask_brain_db/static/images/data
- /etc/letsencrypt:/etc/letsencrypt
Here's the relevant part of my docker-compose.override.yml:
web:
volumes:
- user-data:/usr/src/app/flask_brain_db/static/images/data
nginx:
volumes:
- ./web/flask_brain_db/static:/usr/src/app/flask_brain_db/static
- user-data:/usr/src/app/flask_brain_db/static/images/data
When I run docker-compose up I still get the error associated with attempting to mount that letsencrypt drive. If I actually go and physically comment those lines out in docker-compose.yml I no longer get that error.
Am I doing this wrong?

Resources