I am using docker-compose version 1.25.0, build unknown I have built two backend APIs that need to communicate with each other. Below is my docker-compose.yml file.
version: '0.1'
services:
user_api:
build: ./users
ports:
- "5002:5000"
command: bash start.sh
networks:
- api_network
posts_api:
build: ./posts
links:
- user_api
ports:
- "5001:5000"
command: bash start.sh
networks:
- api_network
networks:
api_network:
driver: bridge
I am getting the following error:
ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for posts_api: 'networks'
Unsupported config option for user_api: 'networks'
I referred to the docker-compose documentation: https://docs.docker.com/compose/networking/
I cannot understand why it is showing unsupported. Please help.
Related
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:
version: '3.7'
services:
docker-mongo:
image:
- mongo:4.2.1
ports:
- "27017:27017"
networks:
- mynetwork
networks:
mynetwork:
When I execute docker-compose config I got the following error:
Version in "./docker-compose.yml" is unsupported. You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/
So according to the error message I tried with version 2.2 and 3.3
both results in the same error message
ERROR: The Compose file './docker-compose.yml' is invalid because:
services.docker-mongo.image contains an invalid type, it should be a string
Ubuntu 18.04.2 LTS
Docker version 18.09.6, build 481bc77
docker-compose version 1.17.1, build unknown
the error message is self explain, your docker-compose should be like below:
version: '3.7'
services:
docker-mongo:
image: mongo:4.2.1
ports:
- "27017:27017"
networks:
- mynetwork
networks:
mynetwork:
I have a Pycharm remote interpreter setup using docker-compose, I am able to run the project fine but when trying to debug I am getting this error:
ERROR: for e21cea317159_my_proj Cannot create container for service myproj: conflicting options: port publishing and the container type network mode
My docker-compose file:
version: '1.0'
services:
my-router:
image: testimage:latest
dns: 10.10.10.10
dns_search:
- testwebsite.com
et:
build:
context: ""
dockerfile: Dockerfile
volumes:
- .:/workarea
depends_on:
- "my-router"
environment:
- WAIT_FOR_PORTS=my-router:12345
network_mode: service:my-router
Thanks for the help!
I am trying to compose a stack using secrets
for development, i use local files in docker/secrets/FILE_NAME
I had this working in windows 10, but I'm struggling to get it to work under win7 toolbox.
I get an error:
Cannot create container for service db:
invalid volume specification:
'C:\project\docker\secrets\DB_USERNAME:/run/secrets/db-username:ro'
I was trying to set COMPOSE_CONVERT_WINDOWS_PATH but unfortunately, this does not change anything. I will get the same output with true or false.
Setting absolute paths did not help either.
Docker compose version 1.16.1 build 6d1ac219
Docker version 17.10.0-ce, build f4ffd25
My docker-compose.yml
version: '3.3'
services:
db:
image: postgres
volumes:
- db-data:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD_FILE=/run/secrets/db-password
- POSTGRES_USER_FILE=/run/secrets/db-username
- POSTGRES_DB_FILE=/run/secrets/db-name
secrets:
- db-username
- db-password
- db-name
web:
build:
context: ./docker/machines/django/
args:
buildno: 1
command: python3 manage.py runserver 0.0.0.0:8000
volumes:
- ./Server:/Server
ports:
- "8000:8000"
depends_on:
- db
secrets:
- db-username
- db-password
- db-name
secrets:
db-username:
file: ./docker/secrets/DB_USERNAME
db-password:
file: ./docker/secrets/DB_PASSWORD
db-name:
file: ./docker/secrets/DB_NAME
volumes:
db-data:
driver: "local"
I've got two Windows Nano docker containers ... one with a service on, the second with my Automated Acceptance Tests.
I'm trying to add a volume to the aat container so I can copy off the tests output.
I've seen elsewhere I'm supposed to use ...
COMPOSE_CONVERT_WINDOWS_PATHS=1
But can't seem to get anywhere :S
version: '3.3'
services:
fancyservice:
restart: always
image: fancyservice
aat-runner:
environment:
- FancyServiceUrl=http://fancyservice/
- COMPOSE_CONVERT_WINDOWS_PATHS=1
volumes:
- .:/output:rw
restart: always
image: aat-runner
I get:
ERROR: for aat_aat-runner_1 Cannot create container for service aat-runner: invalid volume spec "/output"
ERROR: for aat-runner Cannot create container for service aat-runner: invalid volume spec "/output": invalid volume specification: '\output'
ERROR: Encountered errors while bringing up the project.
You have to specify the volume at the same level as "services:" as well as against the individual container ...
version: '3.3'
services:
fancyservice:
restart: always
image: fancyservice
aat-runner:
environment:
- FancyServiceUrl=http://fancyservice/
- COMPOSE_CONVERT_WINDOWS_PATHS=1
volumes:
- .:/output:rw
restart: always
image: aat-runner
volumes:
- aat-output:c:\aat-output\
volumes:
aat-output: