错误:合成文件docker-Compose.yml无效
执行错误:合成文件docker-Compose.yml无效,docker,docker-compose,Docker,Docker Compose,执行docker compose config时,出现以下错误: version: '3.7' services: docker-mongo: image: - mongo:4.2.1 ports: - "27017:27017" networks: - mynetwork networks: mynetwork: 因此,根据错误消息,我尝试使用版本2.2和3.3 两者都会导致相同的错误消息 Version in "./docker-
docker compose config
时,出现以下错误:
version: '3.7'
services:
docker-mongo:
image:
- mongo:4.2.1
ports:
- "27017:27017"
networks:
- mynetwork
networks:
mynetwork:
因此,根据错误消息,我尝试使用版本2.2
和3.3
两者都会导致相同的错误消息
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/
- Ubuntu 18.04.2 LTS
- Docker版本18.09.6,内部版本481bc77
- docker compose版本1.17.1,构建未知
ERROR: The Compose file './docker-compose.yml' is invalid because:
services.docker-mongo.image contains an invalid type, it should be a string
:
services.docker-mongo.image包含无效类型,该类型应为字符串
,其中实际被指控的元素在您的文件中包含一个列表=>image:“mongo:4.2.1”
仅用于完整性:docker Compose默认情况下为您的应用程序设置一个网络,将服务的每个容器添加到默认网络。单个网络上的容器可以访问并发现网络上的每个其他容器。明白为什么是3.7吗?@user2763557这只是docker compose版本,对我来说不是什么大买卖3.0奏效了
version: '3.7'
services:
docker-mongo:
image: mongo:4.2.1
ports:
- "27017:27017"
networks:
- mynetwork
networks:
mynetwork: