unable to override volume mount with docker-compose.override - docker

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?

Related

Docker compose Unsupported config option for service volume mongodb

I am trying to learn docker by reading the official documentation. I am on the task of Use Compose to develop locally. Trying to compose mongodb but I got an error
The Compose file './docker-compose.dev.yml' is invalid because:
Unsupported config option for services.volumes: 'mongodb'
here is docker-compose.dev.yml file:
version: '3.8'
services:
notes:
build:
context: .
ports:
- 8080:8080
- 9229:9229
environment:
- SERVER_PORT=8080
- DATABASE_CONNECTIONSTRING=mongodb://mongo:27017/notes
volumes:
- ./:/code
command: npm run debug
mongo:
image: mongo:4.2.8
ports:
- 27017:27017
volumes:
- mongodb:/data/db
- mongodb_config:/data/configdb
volumes:
mongodb:
mongodb_config:
How can I make it work?
That's a small mistake on your part, the volumes section of the docker-compose.yaml file is related to all services and not one in particular, because of how yaml files are formatted the indentation level matters a lot, in your example you didn't use the volumes parameter, instead you defined a service called volumes and services don't have a parameter called mongodb.
You have to simply decrease the identation level on the last 3 lines and it will work just fine.
version: '3.8'
services:
mongo:
image: mongo:4.2.8
ports:
- 27017:27017
volumes:
- mongodb:/data/db
- mongodb_config:/data/configdb
volumes:
mongodb:
mongodb_config:

The Compose file './docker-compose.yaml' is invalid because: Unsuported config for service: 'pihole'

I have the following docker-compose file and getting this error:
The Compose file './docker-compose.yaml' is invalid because: Unsuported config for service: 'pihole'
docker-compose.yml:
services:
pihole:
container_name: pihole
image: pihole/pihole:latest
ports:
- "53:53/tcp"
- "53:53/udp"
- "67:67/udp"
- "80:80/tcp"
- "443:443/tcp"
environment:
TZ: 'Europe/Zurich'
WEBPASSWORD: 'mySuperSecrectPW'
volumes:
- './etc-pihole/:/etc/pihole/'
- './etc-dnsmasq.d/:/etc/dnsmasq.d/'
dns:
- 127.0.0.1
- 1.1.1.1
cap_add:
- NET_ADMIN
I already stripped every argument that is not absolutely necessary, but still getting the same error. Sorry if that is a stupid question to ask, but I am new to the whole docker topic and still learning.
Compose files that do not declare a version are considered “version 1”. In those files, all the services are declared at the root of the document.
See Compose file versions.
Try adding version: '3.7' or whatever version you like at the top level.

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 of webroot not editable on host machine

I have a docker-compose LAMP stack comprised of three services; a webserver, php and mysql.
The apache2 webroot inside the container is shared to my local machine using a volume like so:
volumes:
- ./public_html:/usr/local/apache2/htdocs
When the stack is running though, I can't edit files inside of the shared volume, since I have a different local user as the user inside the apache2 container. Additionally the installer of my CMS (Processwire) is unable to acquire permissions to the required install directories.
The apache container uses alpine 2.4.35.
I've build my docker-compose file according to this tutorial:
https://medium.com/#thivi/creating-a-lamp-stack-using-docker-compose-13ca4e3950e1
Below I have attached my docker-compose.yml.
version: '3.7'
services:
apache:
build: './apache'
restart: always
ports:
- 80:80
- 443:443
networks:
- frontend
- backend
volumes:
- ./public_html:/usr/local/apache2/htdocs
- ./cert/:/usr/local/apache2/cert/
depends_on:
- php
- mysql
php:
build: './php'
restart: always
networks:
- backend
volumes:
- ./public_html:/usr/local/apache2/htdocs
- ./tmp:/usr/local/tmp
mysql:
build: './mysql'
restart: always
ports:
- 3306:3306
expose:
- 3306
networks:
- backend
volumes:
- ./database:/var/lib/mysql
networks:
backend:
frontend:
Is there any way to fix this issue? I'd be grateful for answers, I've been dealing with this issue for the past 2 days, without getting anywhere and I'm also kind of surprised that such an essential feature like directory sharing is so complicated.
/edit:
I've also noticed something interesting; when I execute a bash inside the apache-container the ownership of apache's document root is set to nobody:nobody, which probably also isn't right.

Why aren't my docker images, built by "docker-compose build", using the correct version of my code?

Docker doesn't use the latest code after running git checkout <non_master_branch>, while I can see it in the vscode.
I am using the following docker-compose file:
version: '2'
volumes:
pgdata:
backend_app:
services:
nginx:
container_name: nginx-angular-dev
image: nginx-angular-dev
build:
context: ./frontend
dockerfile: /.docker/nginx.dockerfile
ports:
- "80:80"
- "443:443"
depends_on:
- web
web:
container_name: django-app-dev
image: django-app-dev
build:
context: ./backend
dockerfile: /django.dockerfile
command: ["./wait-for-postgres.sh", "db", "./django-entrypoint.sh"]
volumes:
- backend_app:/code
ports:
- "8000:8000"
depends_on:
- db
env_file: .env
environment:
FRONTEND_BASE_URL: http://192.168.99.100/
BACKEND_BASE_URL: http://192.168.99.100/api/
MODE_ENV: DOCKER_DEV
db:
container_name: django-db
image: postgres:10
env_file: .env
volumes:
- pgdata:/var/lib/postgresql/data
I have tried docker-compose build --no-cache, followed by docker-compose up --force-recreate but it didn't solve the problem.
What is the root of my problem?
Your volumes: are causing problems. Docker volumes aren't intended to hold code, and you should delete the volume declarations that mention backend_app:.
Your docker-compose.yml file says in part:
volumes:
backend_app:
services:
web:
volumes:
- backend_app:/code
backend_app is a named volume: it keeps data that must be persisted across container runs. If the volume doesn't exist yet the first time then data will be copied into it from the image, but after that, Docker considers it to contain critical user data that must not be updated.
If you keep code or libraries in a Docker volume, Docker will never update it, even if the underlying image changes. This is a common problem in JavaScript applications that mount an anonymous volume on their node_modules directory.
As a temporary workaround, if you docker-compose down -v, it will delete all of the volumes, including the one with your code in it, and the next time you start it will get recreated from the image.
The best solution is to simply not use a volume here at all. Delete the lines above from your docker-compose.yml file. Develop and test your application in a non-Docker environment, and when you're ready to do integration testing, run docker-compose up --build. Your code will live in the image, and an ordinary docker build will produce a new image with new code.

Resources