While running docker-compose up getting the below error:
ERROR: The Compose file './docker-compose.yml' is invalid because:
Invalid top-level property "wordpress". Valid top-level sections for this Compose file are: version, services, networks, volumes, and extensions starting with "x-".
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/
Infra Details:
Docker
Docker version 23.0.0, build e92dd87
docker-compose (installed using apt-get install docker-compose)
docker-compose version 1.25.0, build unknown
docker-compose.yml
version: '3'
wordpress:
image: wordpress
links:
- db:mysql
db:
image: mariadb
environment:
MYSQL_ROOT_PASSWORD: '<a secure password>'
On the top level you should have services and only then the services themselves. Something like this:
version: '3'
services:
wordpress:
image: wordpress
links:
- db:mysql
db:
image: mariadb
environment:
MYSQL_ROOT_PASSWORD: '<a secure password>'
Related
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'm new to docker and trying to understand what docker stack does. Currently trying out this container https://hub.docker.com/r/instapy/instapy
this is the docker-compose file
services:
web:
image: instapy/instapy:latest
container_name: "${COMPOSE_PROJECT_NAME}_web"
env_file: .env
environment:
- PYTHONUNBUFFERED=0
- INSTAPY_WORKSPACE=/code/InstaPy
volumes:
- ./:/code
The errors I'm getting seem to indicate quite a few issues
Ignoring deprecated options:
container_name: Setting the container name is not supported.
service "web": container_name is deprecated
service "web": env_file are ignored
Stack.compose.docker.com "test" is invalid: test: Invalid value: "null": conversion to kube entities failed: C:\Users\roole\instapy-docker\docker-compose: only absolute paths can be specified in mount source
docker compose version info
docker-compose version 1.24.1, build 4667896b
docker-py version: 3.7.3
CPython version: 3.6.8
OpenSSL version: OpenSSL 1.0.2q 20 Nov 2018
Content asked for from ' docker-compose config'
services:
web:
container_name: instapy_web
environment:
COMPOSE_PROJECT_NAME: instapy
INSTAPY_WORKSPACE: /code/InstaPy
PYTHONUNBUFFERED: '0'
image: instapy/instapy:latest
volumes:
- C:\Users\roole\instapy-docker\docker-compose:/code:rw
version: '3.0'
Any help in understanding what the hell I'm supposed to be doing would be mega.
At the beginning of each docker-compose.yml file you need to specify the version. Each version of docker-compose supports certain versions of the yml file specification.
This should work for you:
version: "3.3"
services:
web:
image: instapy/instapy:latest
container_name: "${COMPOSE_PROJECT_NAME}_web"
env_file: .env
environment:
- PYTHONUNBUFFERED=0
- INSTAPY_WORKSPACE=/code/InstaPy
volumes:
- ./:/code
When deploying a stack the container name is not relevant (in fact after version "3" is not supported). The reason for that is that docker needs to be able to change the container name in case you scale your service (multiple versions of the same container might end up running on the same docker instance and then they need to have different container names).
Also when you specify a volume you need to specify full, absolute paths. You can simply replace your volume declaration with what you got from running docker-compose config (C:\Users\roole\instapy-docker\docker-compose:/code:rw) or you can use $PWD or the equivalent for your OS to refer to your current directory
I have a local docker image which has name img_test. My docker-compose.yml file is:
version: '2'
services:
img_test:
image: img_test:latest
ports:
- "8080:80"
mysql:
image: mysql:latest
ports:
- "3636:3036"
nvidia/cuda:
image: nvidia/cuda:latest
runtime: nvidia
command: nvidia-smi
networks:
appnet:
external: true
I also have Dockerfile . When I run the command docker-compose up It throws this error.
ERROR: The Compose file './docker-compose.yml' is invalid because:
Invalid service name 'img_test' - only [a-zA-Z0-9\._\-] characters are allowed
I gave another names such as img/test, imgtest but they did not work.
I also tried build the Dockerfile in docker-compose.yml file by this command.
version: '2'
services:
app:
build: .
It gives same error for app.
What is the solution? I am new on Docker. I tested my image and it is working correctly. I dont want to push my image to Dockerhub. Is there another way to solve this problem?
It's a relatively old version of docker-compose. They had this bug in the past. Try upgrading.
https://github.com/docker/compose/issues/4754
I have the following docker-compose file content:
version: '3.4'
services:
local-app:
build: ./app/
command: node app
ports:
- '7001:7001'
links:
- search-svc
networks:
docker_app-network:
external: true
external_links:
-search-svc
Basically what I 'm trying to do is to link the ' local-app ' container with another already running container the ' search-svc '. By running the docker compose I get the following error:
The Compose file './docker-compose.yaml' is invalid because:
Invalid top-level property "external_links". Valid top-level sections for this Compose file are: secrets, version, volumes, services, configs, networks, and extensions starting with "x-". 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.
I have read the documentation but I can't find any solution to my problem.
Can anyone suggest anything that might help?
Thanks in advance
Yaml files are space sensitive. You tried to define external_links at the top level of the file rather than as part of a service. This should by syntactically correct:
version: '3.4'
services:
local-app:
build: ./app/
command: node app
ports:
- '7001:7001'
links:
- search-svc
external_links:
- search-svc
networks:
docker_app-network:
external: true
That said, linking is deprecated in docker, it is preferred to use a common network (excluding the default bridge network named bridge) and then use the integrated DNS server for service discovery. It looks like you have defined your common network but didn't use it. This would place your service on that network and rely on DNS:
version: '3.4'
services:
local-app:
build: ./app/
command: node app
ports:
- '7001:7001'
networks:
- docker_app-network
networks:
docker_app-network:
external: true
I am using below version of docker and docker-compose -
Docker version 17.03.1-ce, build c6d412e
docker-compose version 1.11.2, build dfed245
I still face issues with -
ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for services.web: 'version'
below is my docker file -
version: '2'
services:
web:
build: .
ports:
- "80:80"
- "443:443"
links:
- memache:memcahced
- solr:solr
- dev_mysql:dev_mysql
container_name: xyz
hostname: XYZ
image: XYZ/mono
version: latest
privileged: true
...
...
Need some assistance.
Don't know if it's just your question, but the indentation of your compose file is off, and there are a number of typos.
Not clear what you're trying to do with that version property in the service definition (no such property is documented), but if you want to specify the version of the image to be used, you do that as follows:
services:
web:
image: XYZ/mono:latest
As already some people pointed out, your indentation is broken. You can verify your docker-compose YAML files with docker-compose config. This checks docker-compose.yml. If you want to check a different YAML, you can specify it with -f, e.g. docker-compose -f docker-compose.prod.yml config