Trying to setup docker for the first time and I'm running into a problem with volumes. I feel pretty confident that the spacing and formatting in the .yml is correct at this point.
I've tried versions 3, 3.1, 3.2, 3.3 and 3.4. All are getting the same error message (below)
Unsupported config option for services.volumes: 'db2_prod'
version: '3'
services:
liberty:
image: liberty:${liberty_tag}
ports:
- "${liberty_ip}:9080:9080"
- "${liberty_ip}:9443:9443"
restart: always
apache:
image: webapp:${apache_tag}
ports:
- "${apache_ip}:80:80"
- "${apache_ip}:443:443"
restart: always
db2:
image: db2:${db2_tag}
ports:
- "${db2_ip}:50000:50000"
stdin_open: true
tty: true
restart: always
volumes:
- db2_prod:/database/stagg3
volumes:
db2_prod:
volumes needs to be at the same indentation with services i.e
services:
#...
volumes:
db2_prod:
version: '3.7'
services:
web:
build: .
command: python /code/manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- 8000:8000
depends_on:
- db
db:
image: postgres:11
volumes:
- postgres_data:/var/lib/postgresql/data/
volumes:
postgres_data:
observe that version, services and volumes have same indent level. Moreover use spacebar for indentation, use of tab may create problem.
Related
I am trying to get a couple of containers up and running, however I am running into some issues. I run this command:
docker-compose up -d --build itvdflab
and get this error
The Compose file './docker-compose.yaml' is invalid because:
Unsupported config option for services: 'itvdelab'
Unsupported config option for networks: 'itvdelabnw'
Here is the yaml file.
services:
itvdelab:
image: itversity/itvdelab
hostname: itvdelab
ports:
- "8888:8888"
volumes:
- "./itversity-material:/home/itversity/itversity-material"
- "./data:/data"
environment:
SHELL: /bin/bash
networks:
- itvdelabnw
depends_on:
- "cluster_util_db"
cluster_util_db:
image: postgres:13
ports:
- "6432:5432"
volumes:
- ./cluster_util_db_scripts:/docker-entrypoint-initdb.d
networks:
- itvdelabnw
environment:
POSTGRES_PASSWORD: itversity
itvdflab:
build:
context: .
dockerfile: images/pythonsql/Dockerfile
hostname: itvdflab
ports:
- "8888:8888"
volumes:
- "./itversity-material:/home/itversity/itversity-material"
- "./data:/data"
environment:
SHELL: /bin/bash
networks:
- itvdelabnw
depends_on:
- "pg.itversity.com"
pg.itversity.com:
image: postgres:13
ports:
- "5432:5432"
networks:
- itvdelabnw
environment:
POSTGRES_PASSWORD: itversity
networks:
itvdelabnw:
name: itvdelabnw
What changes do I need to make to get this working?
Your docker-compose.yml file is missing a version: line. Until very recently, this caused Docker Compose to interpret this as the original "version 1" Compose format, which doesn't have a top-level services: key and doesn't support Docker networks. The much newer Compose Specification claims that a version: key is optional, but in practice if you can't be guaranteed to use a very new version of Compose (built as a plugin to the docker binary) it's required. The most recent Compose file versions supported by the standalone Python docker-compose tool are 3.8 and 2.4 (you need the 2.x version for some resource-related constraints in non-Swarm installations).
# Add at the very beginning
version: '3.8'
Here is the revised copy:
version: '3.4'
services:
itvdelab:
image: itversity/itvdelab
hostname: itvdelab
ports:
- "8888:8888"
volumes:
- "./itversity-material:/home/itversity/itversity-material"
- "./data:/data"
environment:
SHELL: /bin/bash
networks:
- itvdelabnw
depends_on:
- "cluster_util_db"
cluster_util_db:
image: postgres:13
ports:
- "6432:5432"
volumes:
- ./cluster_util_db_scripts:/docker-entrypoint-initdb.d
networks:
- itvdelabnw
environment:
POSTGRES_PASSWORD: itversity
itvdflab:
build:
context: .
dockerfile: images/pythonsql/Dockerfile
hostname: itvdflab
ports:
- "8888:8888"
volumes:
- "./itversity-material:/home/itversity/itversity-material"
- "./data:/data"
environment:
SHELL: /bin/bash
networks:
- itvdelabnw
depends_on:
- "pg.itversity.com"
pg.itversity.com:
image: postgres:13
ports:
- "5432:5432"
networks:
- itvdelabnw
environment:
POSTGRES_PASSWORD: itversity
networks:
itvdelabnw:
name: itvdelabnw
and now I get the following error
ERROR: The Compose file './docker-compose.yaml' is invalid because:
services.pg.itversity.com.networks.itvdelabnw contains unsupported option: 'name'
for me work try different version. In my case work
version: '2.2'
I found this docker compose container on an asian site, and was trying to run it, and then I got the following. I had to modify the docker compose file because there were duplicated characters. I'm not sure why this won't run, and i have looked on stackoverflow for other issues, but none resolved my issue.
The docker compose file is as follows:
---
version: '3.5'
services:
wowonder-web:
container_name: wowonder-web
image: webdevops/php-apache:debian-10
environment:
-WEB_DOCUMENT_ROOT=/app
-PHP_MEMORY_LIMIT=1024M
-PHP_MAX_EXECUTION_TIME=7200
-PHP_POST_MAX_SIZE=10240M
-PHP_UPLOAD_MAX_FILESIZE=10240M
-FPM_MAX_REQUESTS=500
-FPM_PM_MAX_CHILDREN=20
-FPM_PM_START_SERVERS=10
-FPM_PM_MIN_SPARE_SERVERS=5
-FPM_PM_MAX_SPARE_SERVERS=15
volumes:
- /opt/wowonder/app:/appwowonder:/app
restart: unless-stopped
wowonder-db:
container_name: wowonder-db
image: mariadb
environment:
-MYSQL_ROOT_PASSWORD="wowonder"
-MYSQL_PASSWORD="wowonder"
-MYSQL_DATABASE="wowonder"
-MYSQL_USER="wowonder"
volumes:
- /docker/Databases/wowonder:/var/lib/mysqldb
command: --sql-mode="NO_ENGINE_SUBSTITUTION"
restart: unless-stopped
networks:
default:
external:
name: imlala
A few mistypes (check this online YAML validator in the future):
First, as #DavidMaze noted, to create a YAML array in a docker-compose file the most popular option is to create a new line for each element and start with a hyphen and a space right after it, you can browse other options in this SO thread
environment:
- WEB_DOCUMENT_ROOT=/app
- PHP_MEMORY_LIMIT=1024M
- PHP_MAX_EXECUTION_TIME=7200
- PHP_POST_MAX_SIZE=10240M
- PHP_UPLOAD_MAX_FILESIZE=10240M
- FPM_MAX_REQUESTS=500
- FPM_PM_MAX_CHILDREN=20
- FPM_PM_START_SERVERS=10
- FPM_PM_MIN_SPARE_SERVERS=5
- FPM_PM_MAX_SPARE_SERVERS=15
Second, your command for wowonder-db was too much indented, taking it a step back fixed the issue.
volumes:
- /docker/Databases/wowonder:/var/lib/mysqldb
command: --sql-mode="NO_ENGINE_SUBSTITUTION"
restart: unless-stopped
Complete and valid compose file:
---
version: '3.5'
services:
wowonder-web:
container_name: wowonder-web
image: webdevops/php-apache:debian-10
environment:
- WEB_DOCUMENT_ROOT=/app
- PHP_MEMORY_LIMIT=1024M
- PHP_MAX_EXECUTION_TIME=7200
- PHP_POST_MAX_SIZE=10240M
- PHP_UPLOAD_MAX_FILESIZE=10240M
- FPM_MAX_REQUESTS=500
- FPM_PM_MAX_CHILDREN=20
- FPM_PM_START_SERVERS=10
- FPM_PM_MIN_SPARE_SERVERS=5
- FPM_PM_MAX_SPARE_SERVERS=15
volumes:
- /opt/wowonder/app:/appwowonder:/app
restart: unless-stopped
wowonder-db:
container_name: wowonder-db
image: mariadb
environment:
- MYSQL_ROOT_PASSWORD="wowonder"
- MYSQL_PASSWORD="wowonder"
- MYSQL_DATABASE="wowonder"
- MYSQL_USER="wowonder"
volumes:
- /docker/Databases/wowonder:/var/lib/mysqldb
command: --sql-mode="NO_ENGINE_SUBSTITUTION"
restart: unless-stopped
networks:
default:
external:
name: imlala
services:
postgres:
container_name: 'lh-postgres'
image: 'postgres:13'
environment:
POSTGRES_PASSWORD: root
redis:
container_name: 'lh-redis'
image: 'redis:6'
nginx:
container_name: 'lh-nginx'
build: ./nginx
depends_on:
- php-fpm
volumes:
- ./src/lh-app:/var/www/html/app
- ./src/lh-api:/var/www/html/api
ports:
- "80:80"
- "443:443"
php-fpm:
container_name: 'lh-php'
image: docker.io/bitnami/php-fpm:8.0
user: '1000:1000'
build:
context: ./php-fpm
args:
- PHP_ENV= development
depends_on:
- postgres
- redis
volumes:
- ./src/lh-app:/var/www/html/app
- ./src/lh-api:/var/www/html/api
ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for services: 'postgres'
getting this error
I think you are missing some ENV vars.
This is our docker-compose.yml for Postgres
version: '3.9'
services:
db:
image: postgres:latest
restart: "no"
container_name: db
volumes:
- ./database:/var/lib/postgresql/data
ports:
- "8002:5432"
environment:
POSTGRES_PASSWORD: verySecurePassword34058
POSTGRES_USER: root
POSTGRES_DB: myDatabase
networks:
default:
external: true
name: our-network
Other parts of the application, (like Redis, the NodeJS App, etc) are in other docker-compose.yml files, But since they share the same network, they talk to each other.
You have not mentioned version in docker-composer.yml
version: '2'
services:
postgres:
container_name: 'lh-postgres'
image: 'postgres:13'
environment:
POSTGRES_PASSWORD: root
redis:
container_name: 'lh-redis'
image: 'redis:6'
You should include your docker and docker-compose version in the querstion to help us answer you.
It would also be wise to define the version: 'x' element at the top of your compose file.
You may be suffering from an old version of the cli, akin to this question:
docker-compose : Unsupported config option for services service: 'web'
I have a yml file with a configuration to run two containers. Here's the file:
web:
build: ./web
ports:
- "8000:8000"
restart: always
volumes:
- website:/www/
nginx:
build: ./nginx
ports:
- "80:80"
restart: always
links:
- web
volumes:
- website:/www/
volumes:
website:
When I run this I always get the following error:
The Compose file '.\docker-compose.yml' is invalid because:
Unsupported config option for volumes: 'website'
I have googled this and I think this is good as it is now. What is wrong with it?
i think you should add version and services in docker-compose file.
version: '3'
services:
web:
build: ./web
ports:
- "8000:8000"
restart: always
volumes:
- website:/www/
nginx:
build: ./nginx
ports:
- "80:80"
restart: always
links:
- web
volumes:
- website:/www/
volumes:
website:
reference :
docker compose file
getting start with docker-compose
This is how my docker-compose.yml file looks like. As you can see, there is a nginx server, a mongoDB, the main application and for testing a nightwatch and selenium container.
nginx:
container_name: 'nginx'
image: 'nginx:1.11'
restart: 'always'
ports:
- '80:80'
- '443:443'
volumes:
- '/opt/nginx/conf.d:/etc/nginx/conf.d:ro'
- '/opt/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro'
- '/etc/letsencrypt:/etc/letsencrypt'
- '/opt/nginx/www:/var/www:ro'
links:
- 'app'
nightwatch:
container_name: nightwatch
image: 'registry.example.com/project/core:nightwatch'
links:
- selenium
stdin_open: true
tty: true
selenium:
container_name: selenium
image: selenium/standalone-chrome
ports:
- 4444:4444
links:
- app
db:
container_name: db
image: 'mongo:3.4'
restart: 'always'
volumes:
- '/opt/mongo/project/prod:/data/db'
app:
container_name: app
image: 'registry.example.de/project/core:latest'
restart: always
links:
- 'db'
environment:
- ROOT_URL=https://example.com
- MONGO_URL=mongodb://db/db
You can also see, that I'm still using version 1 and I want to upgrade to current version (3). And there are a few problems for converting the file.
For example I do not understand the network option which should be used instead of the deprecated link to get access to containers.
In the nightwatch container I'm running a script like
module.exports = {
'start application': function(browser) {
browser
.url('http://app') // <--
.waitForElementVisible('body', 10000)
.getTitle(function(result) {
this.assert.equal(typeof result, 'string')
})
},
}
So I need to get access to the app container via nightwatch, which also needs selenium. The main app needs of course the db.
I need some help converting to version 3:
version: '3'
services:
nginx:
...
nightwatch:
...
This should be enough:
version: "3"
services:
nginx:
container_name: 'nginx'
image: 'nginx:1.11'
restart: 'always'
ports:
- '80:80'
- '443:443'
volumes:
- '/opt/nginx/conf.d:/etc/nginx/conf.d:ro'
- '/opt/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro'
- '/etc/letsencrypt:/etc/letsencrypt'
- '/opt/nginx/www:/var/www:ro'
links:
- app
nightwatch:
container_name: nightwatch
image: 'registry.example.com/project/core:nightwatch'
links:
- selenium
stdin_open: true
tty: true
selenium:
container_name: selenium
image: selenium/standalone-chrome
ports:
- 4444:4444
links:
- app
db:
container_name: db
image: 'mongo:3.4'
restart: 'always'
volumes:
- '/opt/mongo/project/prod:/data/db'
app:
container_name: app
image: 'registry.example.de/project/core:latest'
restart: always
links:
- db
environment:
- ROOT_URL=https://example.com
- MONGO_URL=mongodb://db/db
You don't need to configure extra networks than the default provided by compose.
Linking containers is still configured as so. Try this:
version: "3"
services:
abc:
image: ubuntu
command: tail -f /dev/null
cde:
image: busybox
command: ping abc
links:
- abc