H5W3
当前位置:H5W3 > docker > 正文

【Docker】docker-compose Unsupported config option

docker-compose.yml 原文件

version: '3'
services:
wordpress:
image: wordpress
ports:
- "80"
environment:
WORDPRESS_DB_HOST: mysql
WORDPRESS_DB_PASSWORD: root
networks:
- my-bridge
mysql:
image: mysql
environment:
MYSQL_ROOT_PASSWD: root
MYSQL_DATABASE: wordpress
volumes:
- mysql-data:/var/bib/mysql
networks:
- my-bridge
volumes:
mysql-data:
networks:
my-bridge:
drive: bridge

$ docker-compose up

ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for services.networks: 'my-bridge'
Unsupported config option for services.volumes: 'mysql-data'

$ docker-compose version

docker-compose version 1.23.2, build 1110ad01
docker-py version: 3.6.0
CPython version: 3.6.7
OpenSSL version: OpenSSL 1.1.0f  25 May 2017

$ docker version

Client:
Version:           18.09.3
API version:       1.39
Go version:        go1.10.8
Git commit:        774a1f4
Built:             Thu Feb 28 06:53:11 2019
OS/Arch:           linux/amd64
Experimental:      false
Server: Docker Engine - Community
Engine:
Version:          18.09.3
API version:      1.39 (minimum version 1.12)
Go version:       go1.10.8
Git commit:       774a1f4
Built:            Thu Feb 28 05:59:55 2019
OS/Arch:          linux/amd64
Experimental:     false

好奇怪的为什么报错??? 我缩进有问题吗?

哭/(ㄒoㄒ)/~~ 马大哈
最终修订版本

version: '3'
services:
wordpress:
image: wordpress
ports:
- 80
environment:
WORDPRESS_DB_HOST: mysql
WORDPRESS_DB_PASSWORD: root
networks:
- my-bridge
mysql:
image: "mysql:5.7.25"
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: wordpress
volumes:
- mysql-data:/var/lib/mysql
networks:
- my-bridge
volumes:
mysql-data:
networks:
my-bridge:
driver: bridge

非常感谢myskies的指导

回答

services:

  wordpress:
    image: wordpress
    ports:
      - "80"
    environment:
      WORDPRESS_DB_HOST: mysql
      WORDPRESS_DB_PASSWORD: root
    networks:
      - my-bridge
    
  mysql:
    image: mysql
    environment:
      MYSQL_ROOT_PASSWD: root
      MYSQL_DATABASE: wordpress
    volumes:
      - mysql-data:/var/bib/mysql
    networks: 
      - my-bridge
  
#  volumes:这个应该放到 wordpress或是mysql下
#    mysql-data:

# 网络和services同级别
networks: 
  my-bridge:
    drive: bridge

本文地址:H5W3 » 【Docker】docker-compose Unsupported config option

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址