Docker compose file:
version: '2'
services:
wordpress:
image: wordpress
ports:
-8080:80
environment:
WORDPRESS_DB_PASSWORD:vvk123
mysql:
image:mysql:latest
environment:
MYSQL_ROOT_PASSWORD:vvk123
when i was tring to execute this command
docker-compose ps
its giving error called
yaml.scanner.ScannerError: mapping values are not allowed here in
".\docker-compose.yml", line 12, column 20
Try adding a space after the column in line 12:
version: '2'
services:
wordpress:
image: wordpress
ports:
- 8080:80
environment:
- WORDPRESS_DB_PASSWORD:vvk123
mysql:
image: mysql:latest
environment:
- MYSQL_ROOT_PASSWORD:vvk123
Related
Can somebody, please, help me to understand what's wrong with my docker-compose.yml file?
version: '3'
services:
jenkins:
container_name: jenkins
image: jenkins/jenkins
ports:
- "8080:8080"
volumes:
- "$PWD/jenkins_home:/var/jenkins_home"
networks:
- net
networks:
net:
I get an error:
ERROR: yaml.parser.ParserError: while parsing a block mapping
in "./docker-compose.yml", line 1, column 1
expected <block end>, but found '<block mapping start>'
in "./docker-compose.yml", line 2, column 3
Try the following. There seem to be multiple issues with your compose file.
version: '3'
services:
jenkins:
container_name: jenkins
image: jenkins/jenkins
ports:
- "8080:8080"
volumes:
- "$PWD/jenkins_home:/var/jenkins_home"
Note: If the following doesn't work, share the full docker-compose.yaml and the Docker compose version.
You should indent lines after services, so the correct form is:
version: '3'
services:
jenkins:
container_name: jenkins
image: jenkins/jenkins
ports:
- "8080:8080"
volumes:
- "$PWD/jenkins_home:/var/jenkins_home"
networks:
- net
networks:
net:
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'
docker-compose.yml:
version: '3'
services:
mysql56:
image: mysql:5.6
container_name: mysql56
volumes:
# - ./mysql:/var/lib/mysql
- ./var:/var
ports:
- 3307:3306
- 33060:33060
environment:
TZ: Asia/Shanghai
MYSQL_ROOT_PASSWORD: 'root#123'
networks:
- shanhy-ci
networks:
shanhy-ci:
driver: bridge
run:
docker-compose up
It outputs error:
Creating mysql56 ... error
...
merged/var/lib: file exists\\\"\"": unknown
ERROR: Encountered errors while bringing up the project.
But if I modify docker-compose.yml:
volumes:
- ./mysql:/var/lib/mysql
# - ./var:/var
So he can work normally, I don't know why,
Why does docker have/var/lib/mysql, but does not have /var?
image: mysql:5.6 : https://github.com/docker-library/mysql/blob/4ee6cf34697d33b2f71144ef55f96867b71220d5/5.6/Dockerfile
docker-compose.yml
services:
db:
image: postgres
environment:
- POSTGRES_PASSWORD=mydbsecretpassword
wordpress:
image: wordpress
ports:
- "8085:80"
While composing the file I am getting the error:
ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for services: 'db'
Docker version is 18.09.5
Docker compose version is 1.17.1
Try adding the compose version: at the top -
version: '3.5'
services:
db:
image: postgres
environment:
- POSTGRES_PASSWORD="mydbsecretpassword"
wordpress:
image: wordpress
ports:
- "8085:80"
Version compatibility - https://docs.docker.com/compose/compose-file/compose-versioning/
There's option to pass command line parameters to the docker-compose so I can have more flexibility with docker compose file. But I have issue and it's not really clear why it happens. So here's the relevant docker compose
filesdocker-compose.yml
version: '2'
services:
mongo:
image: mongo:3.2
restart: always
volumes:
- /mnt/data/mongodb/data/db:/data/db
redis:
image: redis:3
restart: always
application:
build: .
ports:
- "3000:3000"
links:
- mongo:mongo
- redis:redis
restart: always
And another file docker-deploy.yml
version: '2'
services:
application:
image: myregistry.com:5000/myapplication:${APP_VERSION}
links:
- mongo:mongo
- redis:redis
restart: always
Now if I run command line APP_VERSION=stage/1.1 docker-compose -f docker-compose.yml -f docker-deploy.yml pull application to pull the application image with a particular version it fails with output
Pulling application (myregistry:5000/myapplication:stage/1.1:latest)...
ERROR: invalid reference format
Note the latest added at the end. What's going on ? Where did it come from ?
You want this to be:
`version: '2'
services:
application:
image: myregistry.com:5000/myapplication/${APP_VERSION}
links:
- mongo:mongo
- redis:redis
restart: always`
Note that I replaced the : with /
And also set your APP_VERSION=stage:1.1