Docker unable to mount nginx - docker

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.

Related

How to access wacore container which is exiting due to file error present within - "/opt/whatsapp/bin/wait_on_postgres.sh"

I am launching containers via docker-compose, but 2 out of 3 containers are failing stating -:"exec user process caused "exec format error" "
The above error is caused while executing a file places at location /opt/whatsapp/bin/wait_on_postgres.sh, i need to add #!/bin/bash at top of this file.
Problem is, the container is exiting in no time so how to access this file to make necessary changes ??
Below is the docker-compose.yml i am using -:
version: '3'
volumes:
whatsappMedia:
driver: local
postgresData:
driver: local
services:
db:
image: postgres:10.6
command: "-p 3306 -N 500"
restart: always
environment:
POSTGRES_PASSWORD: testpass
POSTGRES_USER: root
expose:
- "33060"
ports:
- "33060:3306"
volumes:
- postgresData:/var/lib/postgresql/data
network_mode: bridge
wacore:
image: docker.whatsapp.biz/coreapp:v${WA_API_VERSION:?Run docker-compose with env var WA_API_VERSION (ex. WA_API_VERSION=2.31.4 docker-compose <command> <options>)}
command: ["/opt/whatsapp/bin/wait_on_postgres.sh", "/opt/whatsapp/bin/launch_within_docker.sh"]
volumes:
- whatsappMedia:/usr/local/wamedia
env_file:
- db.env
environment:
# This is the version of the docker templates being used to run WhatsApp Business API
WA_RUNNING_ENV_VERSION: v2.2.3
ORCHESTRATION: DOCKER-COMPOSE
depends_on:
- "db"
network_mode: bridge
links:
- db
waweb:
image: docker.whatsapp.biz/web:v${WA_API_VERSION:?Run docker-compose with env var WA_API_VERSION (ex. WA_API_VERSION=2.31.4 docker-compose <command> <options>)}
command: ["/opt/whatsapp/bin/wait_on_postgres.sh", "/opt/whatsapp/bin/launch_within_docker.sh"]
ports:
- "9090:443"
volumes:
- whatsappMedia:/usr/local/wamedia
env_file:
- db.env
environment:
WACORE_HOSTNAME: wacore
# This is the version of the docker templates being used to run WhatsApp Business API
WA_RUNNING_ENV_VERSION: v2.2.3
ORCHESTRATION: DOCKER-COMPOSE
depends_on:
- "db"
- "wacore"
links:
- db
- wacore
network_mode: bridge
Problem got resolved by using 64bit guest OS image.
I was running this container over 32 bit Centos which was causing the error.

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 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.

docker-compose error "read-only file system"

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.

Mounting volumes before executing commands with docker-compose and boot2docker

I'm using OSX and I have installed Kitematic which uses boot2docker to run docker and containers. I have created a container which needs to mount some local folder under docker folder and doing that with docker-compose:
web:
build: .
ports:
- "9001:9001"
- "9002:9002"
volumes:
- /projects/test /somepath
- /projects/test2 /someotherpath
command: ant clean all;./server.sh start
when I run docker-compose up it seems that the volume are not mounted before executing the command phase cause I am getting error logs that /somepathand /someotherpath cannot be found.
I do not understand what is wrong with docker-command configuration.
I think you need to replace the space with a colon when mapping volumes. For example:
kafka:
image: wurstmeister/kafka:0.8.2.1
hostname: kafka
ports:
- "9092:9092"
links:
- zookeeper:zk
environment:
KAFKA_ADVERTISED_HOST_NAME: kafka
KAFKA_ADVERTISED_PORT: 9092
volumes:
- /var/run/docker.sock:/var/run/docker.sock

Resources