Cannot bind volume using Windows Docker-Compose - docker

I'm having trouble with a volume in my docker-compose.yml.
docker-compose.yml:
version: "3.3"
services:
prometheus:
image: prom/prometheus:latest
container_name: pg_provi_promentheus
volumes:
- ${PWD}/resources/config/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- pg_provi_prometheus_data:/prometheus
command:
- "--config.file=/etc/prometheus/prometheus.yml"
# - "-storage.local.path=/prometheus"
ports:
- "9090:9090"
node-exporter:
image: prom/node-exporter:latest
container_name: pg_provi_node_exporter
ports:
- "9100:9100"
grafana:
image: grafana/grafana:latest
container_name: pg_provi_grafana
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
- GF_AUTH_ANONYMOUS_ENABLED=true
depends_on:
- prometheus
volumes:
- ${PWD}/resources/config/grafana/provisioning:/etc/grafana/provisioning:ro
- pg_provi_grafana_data:/var/lib/grafana
ports:
- "3000:3000"
volumes:
pg_provi_prometheus_data:
pg_provi_grafana_data:
I constantly get this error message on startup:
[INFO] starting containers
Creating network "pg_provi_default" with the default driver
Creating volume "pg_provi_pg_provi_prometheus_data" with default driver
Creating volume "pg_provi_pg_provi_grafana_data" with default driver
Creating pg_provi_promentheus ... error
Creating pg_provi_node_exporter ... done
ERROR: for pg_provi_promentheus Cannot start service prometheus: OCI runtime create failed: container_linux.go:346: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/mnt/c/Entwicklung/home/_workspace/workspace/provinzial-prometheus-grafana/src/main/localhost/pg_provi/resources/config/prometheus.yml\\\" to rootfs \\\"/var/lib/docker/overlay2/643795a7aff240086c1d48371fd7ded76a52d70a53299b01a253c25a529ec0e5/merged\\\" at \\\"/var/lib/docker/overlay2/643795a7aff240086c1d48371fd7ded76a52d70a53299b01a253c25a529ec0e5/merged/etc/prometheus/prometheus.yml\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: for prometheus Cannot start service prometheus: OCI runtime create failed: container_linux.go:346: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/mnt/c/Entwicklung/home/_workspace/workspace/provinzial-prometheus-grafana/src/main/localhost/pg_provi/resources/config/prometheus.yml\\\" to rootfs \\\"/var/lib/docker/overlay2/643795a7aff240086c1d48371fd7ded76a52d70a53299b01a253c25a529ec0e5/merged\\\" at \\\"/var/lib/docker/overlay2/643795a7aff240086c1d48371fd7ded76a52d70a53299b01a253c25a529ec0e5/merged/etc/prometheus/prometheus.yml\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: Encountered errors while bringing up the project.
Same docker-compose.yml on linux works perfectly fine. I don't get why I cannot mount my prometheus.yml into my container.
Startup and shutdown is straight forward via docker-compose up -d and docker-compose down -v.
Anyone got an idea? Thanks guys.

Related

How to Mount a file from Host to Container via Docker-Compose

Any I missing something simple here. But Im trying to mount a host file to the container via docker-compose. My docker-compose.yml is:
version: '3.2'
services:
myapp_poller:
restart: unless-stopped
image: &myappImage netenglabs/myapp:0.13.0
container_name: myapp_poller
command: -D /myapp/inventory.yml -k
stdin_open: true
tty: true
volumes:
- "parquet-db:/myapp/parquet"
- "./config/inventory.yml:/myapp/inventory.yml"
- "./config/myapp-cfg.yml:/root/.myapp/myapp-cfg.yml"
entrypoint:
- sq-poller
If I go into ./config and run docker-compose up -d I get:
ERROR: for myapp_poller Cannot start service myapp_poller: OCI runtime create failed: container_linux.go:367: starting container process caused: process_linux.go:495: container init caused: rootfs_linux.go:60: mounting "/run/desktop/mnt/host/wsl/docker-desktop-bind-mounts/Ubuntu-20.04/cc227aed2745c686a488b2a5b99142480733c23c6aa9f72f7d7cb77b4506cee2" to rootfs at "/var/lib/docker/overlay2/8b2cfc582829f784a1a918ba17ef667d2d4c4291b9c0d6655f6f813da486e333/merged/root/.myapp/myapp-cfg.yml" caused: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
Thanks,

Do I need to create my own nginx.conf file to run this docker-composer.yml file succesfully?

I am trying to get a nextcloud + mariadb + nginx docker-compose up and running locally, but I am stuck when it comes to the nginx.conf file. I am following this guide at the base-fpm section. Here is the docker-compose.yml file, what I ran in my CLI and the error i got:
version: '2'
volumes:
nextcloud:
db:
services:
db:
image: mariadb
restart: always
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
volumes:
- db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=mypw
- MYSQL_PASSWORD=mypw
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
app:
image: nextcloud:fpm
restart: always
links:
- db
volumes:
- nextcloud:/var/www/html
environment:
- MYSQL_PASSWORD=mypw
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
- MYSQL_HOST=db
web:
image: nginx
restart: always
ports:
- 8080:80
links:
- app
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
volumes_from:
- app
$ docker-compose up
Creating network "nextcloud_default" with the default driver
Creating volume "nextcloud_nextcloud" with default driver
Creating volume "nextcloud_db" with default driver
Creating nextcloud_db_1 ... done
Creating nextcloud_app_1 ... done
Creating nextcloud_web_1 ... error
ERROR: for nextcloud_web_1 Cannot start service web: OCI runtime create failed:
container_linux.go:370: starting container process caused: process_linux.go:459: container init
caused: rootfs_linux.go:59: mounting "/home/nowak/docker/nextcloud/nginx.conf" to rootfs at
"/var/lib/docker/overlay2/4869db7f0302ec8b7e5f4328b861e64627daa78728d443913052cecd1cd095a9/merge
d/etc/nginx/nginx.conf" caused: not a directory: unknown: Are you trying to mount a directory
onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: for web Cannot start service web: OCI runtime create failed: container_linux.go:370:
starting container process caused: process_linux.go:459: container init caused:
rootfs_linux.go:59: mounting "/home/nowak/docker/nextcloud/nginx.conf" to rootfs at
"/var/lib/docker/overlay2/4869db7f0302ec8b7e5f4328b861e64627daa78728d443913052cecd1cd095a9/merge
d/etc/nginx/nginx.conf" caused: not a directory: unknown: Are you trying to mount a directory
onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: Encountered errors while bringing up the project.
Do I need to create a nginx.conf file and place it in my work directory?
The guide does mention this:
The configuration for nginx is stored in the configuration file nginx.conf, that is mounted into the container. An example can be found in the examples section here.
But when I follow that link, I can't seem to find any example of nginx.conf files.
Looks like other people are also searching for the file, so I'll add the link from my comment to the right file here:
https://github.com/nextcloud/docker/blob/master/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/web/nginx.conf

Docker: volume under bind mount?

Here's what I've got:
version: "3.7"
services:
php:
build:
context: .
dockerfile: docker/php.docker
links:
- mariadb
env_file: .env
volumes:
- type: volume
source: webpack_assets
target: /srv/myproject/.webpack
read_only: true
- type: volume
target: /srv/myproject/storage
consistency: delegated
- type: tmpfs
target: /srv/myproject/bootstrap/cache
consistency: delegated
- type: bind
source: .
target: /srv/myproject
read_only: true
consistency: cached
working_dir: '/srv/myproject'
webpack:
image: node:lts
ports:
- '8081:8081'
env_file: .env
volumes:
- type: volume
source: webpack_assets
target: /srv/myproject/.webpack
- type: bind
source: .
target: /srv/myproject
read_only: true
consistency: cached
working_dir: '/srv/myproject'
command: sh -c 'yarn && exec node --max_old_space_size=8192 node_modules/.bin/webpack-dev-server'
volumes:
webpack_assets:
webpack needs read-only access to my project files and it needs to write a special file webpack-assets.json which I've moved under a .webpack directory because I don't think you can mount a single file.
php needs read-only access to this generated file. I would have liked to make it a tmpfs volume but apparently those can't be shared?? The host system doesn't need access to this file.
The problem is I get this error when I try to try to mount the volumes this way:
ERROR: for myproject_webpack_1 Cannot start service webpack: OCI runtime create failed: container_linux.go:346: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/var/lib/docker/volumes/myproject_webpack_assets/_data\\\" to rootfs \\\"/var/lib/docker/overlay2/bc6896fa1823fbb96963b5afd02ac877b6210ed25712be697c226dc1d1943762/merged\\\" at \\\"/var/lib/docker/overlay2/bc6896fa1823fbb96963b5afd02ac877b6210ed25712be697c226dc1d1943762/merged/srv/myproject/.webpack\\\" caused \\\"mkdir /var/lib/docker/overlay2/bc6896fa1823fbb96963b5afd02ac877b6210ed25712be697cRecreating myproject_php_1 ... error
ERROR: for myproject_php_1 Cannot start service php: OCI runtime create failed: container_linux.go:346: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/var/lib/docker/volumes/myproject_webpack_assets/_data\\\" to rootfs \\\"/var/lib/docker/overlay2/ee4f18947f74ba66fa17775e1b32447e9536609ad527699f3de74ec101d32915/merged\\\" at \\\"/var/lib/docker/overlay2/ee4f18947f74ba66fa17775e1b32447e9536609ad527699f3de74ec101d32915/merged/srv/myproject/.webpack\\\" caused \\\"mkdir /var/lib/docker/overlay2/ee4f18947f74ba66fa17775e1b32447e9536609ad527699f3de74ec101d32915/merged/srv/myproject/.webpack: read-only file system\\\"\"": unknown
ERROR: for webpack Cannot start service webpack: OCI runtime create failed: container_linux.go:346: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/var/lib/docker/volumes/myproject_webpack_assets/_data\\\" to rootfs \\\"/var/lib/docker/overlay2/bc6896fa1823fbb96963b5afd02ac877b6210ed25712be697c226dc1d1943762/merged\\\" at \\\"/var/lib/docker/overlay2/bc6896fa1823fbb96963b5afd02ac877b6210ed25712be697c226dc1d1943762/merged/srv/myproject/.webpack\\\" caused \\\"mkdir /var/lib/docker/overlay2/bc6896fa1823fbb96963b5afd02ac877b6210ed25712be697c226dc1d1943762/merged/srv/myproject/.webpack: read-only file system\\\"\"": unknown
ERROR: for php Cannot start service php: OCI runtime create failed: container_linux.go:346: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/var/lib/docker/volumes/myproject_webpack_assets/_data\\\" to rootfs \\\"/var/lib/docker/overlay2/ee4f18947f74ba66fa17775e1b32447e9536609ad527699f3de74ec101d32915/merged\\\" at \\\"/var/lib/docker/overlay2/ee4f18947f74ba66fa17775e1b32447e9536609ad527699f3de74ec101d32915/merged/srv/myproject/.webpack\\\" caused \\\"mkdir /var/lib/docker/overlay2/ee4f18947f74ba66fa17775e1b32447e9536609ad527699f3de74ec101d32915/merged/srv/myproject/.webpack: read-only file system\\\"\"": unknown
How can I get this to work?

Docker mounting rootfs caused not a directory error

I've been trying docker-compose up -d to my container but causes this error below:
ERROR: for phpsample-feed_phpsample_1 Cannot start service phpsample: OCI runtime create failed:
container_linux.go:346: starting container process caused "process_linux.go:449: container init caused
\"rootfs_linux.go:58: mounting \\"/c/Users/testUser/Documents/phpsample-feed/src\\" to rootfs
\\"/mnt/sda1/var/lib/docker/overlay2/e6bf66b01f587c8826c2944b676044c6a199a0c8c2b8807adf13de0e0f8c4509/
merged\\" at \\"/mnt/sda1/var/lib/docker/overlay2/e6bf66b01f587c8826c2944b676044c6a199a0c8c2b8807adf13de0e0f8c4509/
merged/var/www/html\\" caused \\"not a directory\\"\"": unknown: Are you trying to mount a directory
onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
Here is my docker-compose.yml file:
version: '3.7'
services:
phpsample:
build:
context: .
init: true
ports:
- '8080:80'
depends_on:
- db
- redis
volumes:
- ./src:/var/www/html:rw
environment:
- DB_HOST=db
- DB_USR=user
- DB_PW=test
- DB_DBNAME=phpsample
- DB_DBPREFIX=dev_
- IS_SHORT_URL=1
- CACHE_DRIVER=redis
- CACHE_HOST=redis
- CACHE_PORT=6379
- CACHE_REDIS_DB=3
- DEBUG=false
restart: always
db:
image: mysql:8
environment:
- MYSQL_ROOT_PASSWORD=test
- MYSQL_USER=user
- MYSQL_PASSWORD=test
- MYSQL_DATABASE=phpsample
volumes:
- db_data:/var/lib/msyql
command: --default-authentication-plugin=mysql_native_password --sql_mode=NO_ENGINE_SUBSTITUTION
redis:
image: redis:5-buster
init: true
command: ["redis-server", "--appendonly", "yes"]
volumes:
- redis_data:/data
volumes:
db_data:
redis_data:
My system and tools used:
Windows 10 Home
Docker Toolbox Terminal
Kitematic
Oracle VM
I've also tried editing my Shared Folders on VM by doing this. With the settings below:
Name: c/Users Path: C:\Users
src should be a directory containing your web content, not a file.
In docker-compose.yaml file make sure that input yaml file path is exist under volumes:

Docker compose up error: container-linux.go: 348

When I typed "docker-compose up", I got this error:
Starting elasticsearch-1 ... error
ERROR: for elasticsearch-1 Cannot start service elasticsearch-1:
b'OCI runtime create failed: container_linux.go:348: starting
container process caused "process_linux.go:402: container init caused
\"rootfs_linux.go:58: mounting
\\\"/c/Users/user/Desktop/data/elasticsearch.yml\\\" to rootfs
\\\"/mnt/sda1/var/lib/docker/aufs/mnt/3ec70a7ad26a47f6537aed2ac091eb2507dfb4de983183b0e669832229f948d7\\\"
at
\\\"/mnt/sda1/var/lib/docker/aufs/mnt/3ec70a7ad26a47f6537aed2ac091eb2507dfb4de983183b0e669832229f948d7/usr/share/elasticsearch/config/elasticsearch.yml\\\"
caused \\\"not a directory\\\"\"": unknown: Are you trying to
mount a directory onto a file (or vice-versa)? Check if the specified
host path exists and is the expected type'
Docker-compose.yml contains the following:
From: http://blog.sandeepchivukula.com
elasticsearch-1:
image: elasticsearch
container_name: elasticsearch-1
ports:
- "9200:9200"
- "9300:9300"
volumes:
- ./data/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
command: elasticsearch
kibana-frontend:
image: kibana:latest
container_name: kibana-frontend
ports:
- "5601:5601"
links:
- elasticsearch-1:elasticsearch
Could you please help me solve this error?
Any help will be appreciated
Thank you in advance
I had the same problem today, and I found the solution for my case in this GitHub Thread:
Cause: I had to change my Windows password today
Solution: The error stopped after going into Docker settings -> Shared Drives, un-selecting my drive (+ Apply), restarting Docker app and then re-selecting (+ Apply).
Kudos to danielcgithub!
Clone (or download the ZIP) of the whole project from GIT and start the docker inside the project folder:
#git clone https://github.com/sandeep/photosearch/?utm_source=sandeepchivukula.com&utm_medium=blog&utm_campaign=photosearch
#cd photosearch
#docker compose up
You can not bind a volume on a single file.
Either you bind the entire directory:
elasticsearch-1:
image: elasticsearch
container_name: elasticsearch-1
ports:
- "9200:9200"
- "9300:9300"
volumes:
- ./data/:/usr/share/elasticsearch/config/
command: elasticsearch
Or you can use docker configs (see further documentation here):
elasticsearch-1:
image: elasticsearch
container_name: elasticsearch-1
ports:
- "9200:9200"
- "9300:9300"
configs:
- source: elasticsearch_config
target: /usr/share/elasticsearch/config/elasticsearch.yml
command: elasticsearch
configs:
elasticsearch_config:
file: ./data/elasticsearch.yml

Resources