Reputation: 140
This is my docker-stack.yml file
version: "3"
services:
mysql:
image: mysql:latest
deploy:
replicas: 1
update_config:
parallelism: 1
restart_policy:
condition: on-failure
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: <Censored>
MYSQL_USER: <Censored>
MYSQL_PASSWORD: <Censored>
volumes:
- ./db/data:/var/lib/mysql
- ./db/logs:/var/log/mysql
- ./db/config:/etc/mysql/conf.d
php:
image: wiput1999/php
volumes:
- ./web:/web
nginx:
image: nginx:latest
ports:
- "80:80"
- "443:443"
volumes:
- ./code:/code:ro
- ./site.conf:/etc/nginx/conf.d/default.conf
- /etc/letsencrypt:/etc/letsencrypt
- ./nginx/log:/var/log/nginx
When I run this following stack I got mysql and nginx with this error "invalid mount config for type "bind": bind source path does not exist"
I have no idea what wrong with my code.
Upvotes: 4
Views: 10517
Reputation: 153
Please consider to use docker configs and docker secrets in place of volumes.
version: "3.3"
services:
nginx:
configs:
- source: nginx_vhost
target: /etc/nginx/conf.d/default.conf
secrets:
- ssl_private_key
...
configs:
nginx_vhost:
file: ./site.conf
secrets:
ssl_private_key:
file: /etc/letsencrypt/private.key
https://docs.docker.com/engine/swarm/configs/ and https://docs.docker.com/compose/compose-file/#configs
Upvotes: 6
Reputation: 27080
bind
is a type of mount that is used to mount a directory (or a file) on the host into the container. All of your volumes are set up like that. So one of your source directories (or files) do not exists on the host. Check each of these:
You could execute ls -ld ./db/data ./db/logs ./db/config ./web ./code ./site.conf /etc/letsencrypt ./nginx/log >/dev/null
and look at the error message to find out which one.
Upvotes: 10