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:
Related
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
Trying to install nextcloud with docker on windows (Docker version: 19.03.13) and I'm starting windows powershell with admin rights, and using docker-compose up -d.
my compose yaml looks like this:
version: '3'
services:
proxy:
image: jwilder/nginx-proxy:alpine
labels:
- "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true"
container_name: nextcloud-proxy
networks:
- nextcloud_network
ports:
- 80:80
- 443:443
volumes:
- ./proxy/conf.d:/etc/nginx/conf.d:rw
- ./proxy/vhost.d:/etc/nginx/vhost.d:rw
- ./proxy/html:/usr/share/nginx/html:rw
- ./proxy/certs:/etc/nginx/certs:ro
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/tmp/docker.sock:ro
restart: unless-stopped
letsencrypt:
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: nextcloud-letsencrypt
depends_on:
- proxy
networks:
- nextcloud_network
volumes:
- ./proxy/certs:/etc/nginx/certs:rw
- ./proxy/vhost.d:/etc/nginx/vhost.d:rw
- ./proxy/html:/usr/share/nginx/html:rw
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
restart: unless-stopped
db:
image: mariadb
container_name: nextcloud-mariadb
networks:
- nextcloud_network
volumes:
- db:/var/lib/mysql
- /etc/localtime:/etc/localtime:ro
environment:
- MYSQL_ROOT_PASSWORD=1984cstr
- MYSQL_PASSWORD=cstrike
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
restart: unless-stopped
app:
image: nextcloud:latest
container_name: nextcloud-app
networks:
- nextcloud_network
depends_on:
- letsencrypt
- proxy
- db
volumes:
- nextcloud:/var/www/html
- ./app/config:/var/www/html/config
- ./app/custom_apps:/var/www/html/custom_apps
- ./app/data:/var/www/html/data
- ./app/themes:/var/www/html/themes
- /etc/localtime:/etc/localtime:ro
environment:
- VIRTUAL_HOST=nextcloud.example.de
- LETSENCRYPT_HOST=nextcloud.example.de
- LETSENCRYPT_EMAIL=realmail#gmail.com
restart: unless-stopped
volumes:
nextcloud:
db:
networks:
nextcloud_network:
But I'm getting the following errors:
ERROR: for nextcloud-mariadb Cannot start service db: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused "rootfs_linux.go:58: mounting \"/etc/localtime\" to rootfs \"/var/lib/docker/overlay2/5111ae9606906d7a02c039fc8ea7987272d4b2738dabd763fde72bdf56c8bb59/merged\" at \"/var/lib/docker/overlay2/5111ae9606906d7a02c039fc8ea7987272d4b2738dabd763fde72bdf56c8bb59/merged/usr/share/zoneinfo/Etc/UTC\" caused \"not a directory\""": unknown: Are you trying to mount a directory onto a file (or vice-versa)? ChCreating nextcloud-proxy ... done
Creating nextcloud-letsencrypt ... done
ERROR: for db Cannot start service db: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused "rootfs_linux.go:58: mounting \"/etc/localtime\" to rootfs \"/var/lib/docker/overlay2/5111ae9606906d7a02c039fc8ea7987272d4b2738dabd763fde72bdf56c8bb59/merged\" at \"/var/lib/docker/overlay2/5111ae9606906d7a02c039fc8ea7987272d4b2738dabd763fde72bdf56c8bb59/merged/usr/share/zoneinfo/Etc/UTC\" 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.
What is wrong? Or what additional Information do I need to provide so that the problem can be found?
Since you are on a Windows host, the mount paths like /etc/localtime won’t work because they don’t exist on your system. The configuration you are using is for a Linux-based host.
Although, it’s recommended, you can remove those mounts from your services.
But, keep in mind that you need to keep the docker socket mount, and you will need to adjust it for a Windows host (since the one you have is also for a Linux host). You can try some solution from here.
I designed a docker-compose.yml file that also supposed to work with individual volumes.
I created a raid-drive which is mounted as /dataraid to my system. I can read/write to the system, but when using it in my compose file, I get read-only file system error messages.
Adjusting the volumes to a other path like /home/myname/test the compose file works.
I have no idea what the /dataraid makes it "read-only".
What are the permissions settings a compose file needs?
error message:
ERROR: for db Cannot start service db: error while creating mount source path '/dataraid/nextcloud/mariadb': mkdir /dataraid: read-only file system
compose:
version: '3'
services:
db:
image: mariadb
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
restart: always
volumes:
- /dataraid/nextcloud/mariadb:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=PASSWORD
env_file:
- db.env
redis:
image: redis
restart: always
app:
image: nextcloud:fpm
restart: always
volumes:
- /dataraid/nextcloud/html:/var/www/html
environment:
- MYSQL_HOST=db
env_file:
- db.env
depends_on:
- db
- redis
web:
build: ./web
restart: always
volumes:
- /dataraid/nextcloud/html:/var/www/html:ro
environment:
- VIRTUAL_HOST=name.de
- LETSENCRYPT_HOST=name.de
- LETSENCRYPT_EMAIL=x#y.de
depends_on:
- app
ports:
- 4080:80
networks:
- proxy-tier
- default
collabora:
image: collabora/code
expose:
- 9980
cap_add:
- MKNOD
environment:
- domain=name.de
- VIRTUAL_HOST=name.de
- VIRTUAL_PORT=9980
- VIRTUAL_PROTO=https
- LETSENCRYPT_HOST=name.de
- LETSENCRYPT_EMAIL=x#y.de
- username= #optional
- password= #optional
networks:
- proxy-tier
restart: always
cron:
build: ./app
restart: always
volumes:
- /dataraid/nextcloud/html:/var/www/html
entrypoint: /cron.sh
depends_on:
- db
- redis
proxy:
build: ./proxy
restart: always
ports:
- 443:443
- 80:80
environment:
- VIRTUAL_PROTO=https
- VIRTUAL_PORT=443
labels:
com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true"
volumes:
- /dataraid/nextcloud/nginx-certs:/etc/nginx/certs:ro
- /dataraid/nextcloud/nginx-vhost.d:/etc/nginx/vhost.d
- /dataraid/nextcloud/nginx-html:/usr/share/nginx/html
- /dataraid/nextcloud/nginx-conf.d:/etc/nginx/conf.d
- /var/run/docker.sock:/tmp/docker.sock:ro
networks:
- proxy-tier
letsencrypt-companion:
image: jrcs/letsencrypt-nginx-proxy-companion
restart: always
volumes:
- /dataraid/nextcloud/nginx-certs:/etc/nginx/certs
- /dataraid/nextcloud/nginx-vhost.d:/etc/nginx/vhost.d
- /dataraid/nextcloud/nginx-html:/usr/share/nginx/html
- /var/run/docker.sock:/var/run/docker.sock:ro
networks:
- proxy-tier
depends_on:
- proxy
networks:
proxy-tier:
see error messages:
bernd#sys-dock:/dataraid/Docker-Configs/nextcloud$ docker-compose up -d
Creating network "nextcloud_default" with the default driver
Creating network "nextcloud_proxy-tier" with the default driver
Creating nextcloud_db_1 ...
Creating nextcloud_proxy_1 ... error
Creating nextcloud_db_1 ... error
Creating nextcloud_collabora_1 ...
ERROR: for nextcloud_proxy_1 Cannot start service proxy: error while creating mount source path '/dataraid/nextcloud/nginx-certs': mkdir /dataraid: read-only file system
Creating nextcloud_redis_1 ... done
Creating nextcloud_collabora_1 ... done
ERROR: for proxy Cannot start service proxy: error while creating mount source path '/dataraid/nextcloud/nginx-certs': mkdir /dataraid: read-only file system
ERROR: for db Cannot start service db: error while creating mount source path '/dataraid/nextcloud/mariadb': mkdir /dataraid: read-only file system
ERROR: Encountered errors while bringing up the project.
If docker starts before the filesystem gets mounted, you could be seeing issues with the docker engine trying to write to the parent filesystem. You can restart the docker daemon to rule this out (systemctl restart docker in systemd base environments).
If restarting the daemon helps, then you can add a dependency between the docker engine and the external filesystem mounts. In systemd, that involves an After= clause in the unit file. E.g. you could create a /etc/systemd/system/docker.service.d/override.conf file containing:
[Unit]
After=nfs-client.target
(Note that I'm not sure that nfs-client.target is the correct unit file for your
filesystem, you'll want to check where it gets mounted.)
Another issue I've seen people encounter recently is Snap based docker installs, which run docker inside of another container technology, which would prevent access to paths not explicitly configured in the Snap.
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
I'm having issues setting up Docker for the first time on a Windows using the Docker Toolbox. Everything works except nginx at the moment.
Error message:
ERROR: for web Cannot start service web: 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/wamp64/www/cathaypacific_career/ops/nginx/default.conf\\\" to rootfs \\\"/mnt/sda1/var/lib/docker/aufs/mnt/ff9b27a89b26b0e9091264d04d3a475f18469db3cf3be473c005e2d4c7d4b5ef\\\" at \\\"/mnt/sda1/var/lib/docker/aufs/mnt/ff9b27a89b26b0e9091264d04d3a475f18469db3cf3be473c005e2d4c7d4b5ef/etc/nginx/conf.d/default.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.
Docker-compose config:
version: '3'
services:
web:
container_name: web
image: nginx:1.13.3-alpine
networks:
- web_tier
ports:
- 80:80
volumes:
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
- ../:/code
- /code/ops/
depends_on:
- app
app:
container_name: app
build: ./php/
networks:
- web_tier
- app_tier
expose:
- '9000'
volumes:
- ./php/settings.conf:/usr/local/etc/php-fpm.d/settings.conf
- ../:/code
- /code/ops/
working_dir: /code
entrypoint: "/bin/sh -c"
command:
- "php-fpm"
env_file: ../.env
depends_on:
- db
db:
container_name: db
image: mysql:5.6.39
networks:
- app_tier
- db_tier
expose:
- '3306'
ports:
- 3306:3306
volumes:
- db_data:/var/lib/mysql
- ./db:/etc/mysql/conf.d
restart: always
env_file: ../.env
networks:
web_tier:
driver: bridge
app_tier:
driver: bridge
db_tier:
driver: bridge
volumes:
db_data:
The issue seems to be related to Nginx with the default.conf not being accessible or the app thinkgs it's a folder and not a file.
I checked the issue online and people suggests to mount the C: folder so I tried to mount it on Oracle VirtualBox and re-run the docker-compose up command but it didn't solve the issue.
Any idea?
I solved same problem with sharing folder with Oracle VirtualBox VM default
Share your project folder and restart your vm.
You can do even with command like
docker-machine stop default & docker-machine stop default
Now, you need to use shared name (project) instead of . in your compose file (docker-compose.yml)
For your case,
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
should changed to
- /sharename/nginx/default.conf:/etc/nginx/conf.d/default.conf
Now try with docker-compose up.
It worked for me.