docker-compose volumes: ./var:/var error? - docker

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

Related

Docker-Compose: service "xxx" depends on undefined service "xxx": invalid compose project

So I looked at this article: link
And I don't see the problem I made, so that's why I am asking.
The error I am getting is:
service "Appback" depends on undefined service -Sql-server: invalid compose project
And my docker-compose.yml file looks like this:
version: '3.8'
services:
Sql-server:
image: mysql:latest
environment:
MYSQL_DATABASE: *****
MYSQL_USER: ****
MYSQL_PASSWORD: *****
MYSQL_ROOT_PASSWORD: *****
ports:
- 3306:3306
expose:
- 3306
volumes:
- db:/var/lib/mysql
networks:
- appnetwork
Appback:
build:
context: ./AppBack
dockerfile: Dockerfile
ports:
- 8080:8080
depends_on:
-Sql-server:
condition: service_started
networks:
- appnetwork
appfront:
build:
context: ./appfront
dockerfile: Dockerfile
ports:
- 3000:3000
depends_on:
-Appback:
condition: service_started
networks:
- appnetwork
volumes:
db:
networks:
appnetwork:
driver: bridge
I don't see where the problem might be as I am also new to docker compose.
You should separate the -Sql-server: with a space - Sql-server: from the first hyphen character.
I saw the same error when you have -Appback: in the next few lines.

Invalid docker.compose.yaml file

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'

Error in docker compose with service application

ERROR: The Compose file '.\docker-compose.yml' is invalid because: Unsupported config option for services.db: 'pessoa'
My docker-compose
version: '3.7'
services:
db:
image: felipe/postgresql-pessoa
build:
context: .
dockerfile: Dockerfile
environment:
TZ: Americana/Sao_Paulo
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 123
POSTGRES_DBNAME: postgres
ports:
- "5435:5435"
networks:
- pessoa-network
pessoa:
image: felipe/pessoa-udemy
restart: always
build: ./Pessoa
work_dir: /Pessoa
environment:
TZ: Americana/Sao_Paulo
SPING_BOOT_ENVIRONMENT: Production
volumes:
- ./Pessoa: /Pessoa
- ~/ .m2:/root/ .m2
ports:
- "8082:8082"
command: mvn clean spring-boot:run
links:
- db
depends_on:
- db
networks:
- pessoa-network
networks:
pessoa-network:
driver: bridge
Better to test docker-compose online validator as there is indentation issue in the compose file.
Also, there is no config option work_dir it should be working_dir
Here is the fix docker-compose file.
version: '3.7'
services:
db:
image: felipe/postgresql-pessoa
build:
context: .
dockerfile: Dockerfile
environment:
TZ: Americana/Sao_Paulo
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 123
POSTGRES_DBNAME: postgres
ports:
- "5435:5435"
networks:
- pessoa-network
pessoa:
image: felipe/pessoa-udemy
restart: always
build: ./Pessoa
working_dir: /Pessoa
environment:
TZ: Americana/Sao_Paulo
SPING_BOOT_ENVIRONMENT: Production
volumes:
- "./Pessoa:/Pessoa"
ports:
- "8082:8082"
command: mvn clean spring-boot:run
links:
- db
depends_on:
- db
networks:
- pessoa-network
networks:
pessoa-network:
driver: bridge

Docker compose unsupported config option

I'm trying to setup a docker to run mysql Mosquitto and node red but keep getting the unsupported config option errors..
Services:
mysql:
image: mysql
container_name: mysql
restart: always
ports:
- “6603:3306”
Environment:
MYSQL_ROOT_PASSWORD: “abcd1234”
volumes:
- mysql-data
node-red:
image: nodered/node-red:latest
restart: always
container_name: nodered
environment:
-TZ=Europe/London
depends_on:
- mysql
ports:
- “1880:1880”
links:
- mysql:mysql
- mosquitto:mosquitto
volumes:
- node-red-data
mosquitto:
image: eclipse-mosquitto
hostname: mosquitto
container_name: mosquitto
restart: always
ports:
- "1883:1883"
volumes:
mysql-data:
node-red-data:
Any thoughts on why im getting these errors?
Unsupported config option for Services: 'mosquitto'
Unsupported config option for volumes: 'mysql-data'

docker-compose: Unsupported config option for services.db: 'jupyter'

I am trying to learn how to utilize docker-compose and was following instructions until I received an error. Here's my docker-compose file.
version: '3'
services:
db:
image: postgres:11.2-alpine
volumes:
- ./pgdata:/var/lib/postgresql/data
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRESS_PASSWORD=${POSTGRESS_PASSWORD}
jupyter:
images: jupyter/scipy-notebook:17aba6048f44
volume:
- ./:/home/notebook
ports:
- "8888:8888"
When I go back and enter "docker-compose up -d --build", I would get an error saying
The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for services.db: 'jupyter'
My docker-compose version is 1.23.2 and trying to run this on Mac. Any ideas? thanks in advance.
I'm sorry, I'm not good at English, so I'm referring to this question.
Edit it like below
version: '3'
services:
db:
image: postgres:11.2-alpine
volumes:
- ./pgdata:/var/lib/postgresql/data
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRESS_PASSWORD=${POSTGRESS_PASSWORD}
jupyter:
image: jupyter/scipy-notebook:17aba6048f44
volumes:
- ./:/home/notebook
ports:
- "8888:8888"
version: '3'
services:
db:
image: postgres:11.2-alpine
volumes:
- ./pgdata:/var/lib/postgresql/data
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRESS_PASSWORD=${POSTGRESS_PASSWORD}
jupyter:
image: jupyter/scipy-notebook:65761486d5d3
volumes:
- ./:/home/notebook
ports:
- "8888:8888"
version: '3'
services:
db:
image: postgres:11.2-alpine
volumes:
- ./pgdata:/var/lib/postgresql/data
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRESS_PASSWORD=${POSTGRESS_PASSWORD}
jupyter:
image: jupyter/scipy-notebook:17aba6048f44 # you write "images" but actually it should be image
volume:
- ./:/home/notebook
ports:
- "8888:8888"

Resources