撰写文件'./docker-compose.yml'无效,因为:不支持的配置选项

时间:2019-05-20 17:20:12

标签: docker docker-compose

我有以下docker-compose文件并收到此错误,

The Compose file './docker-compose.yml' is invalid because: Unsupported config option

docker-compose.yml:

version: "3"

services:
  webserver:
    build: 
      context: ./bin/webserver
    container_name: 'png-webserver'
    restart: 'always'
    ports:
      - "81:81"
      - "444:444"
    links: 
      - mysql
    volumes: 
      - /var/www/vhost/dev.ivacy.com:/var/www/html
      - ${PHP_INI-./config/php/php.ini}:/usr/local/etc/php/php.ini
      - ${VHOSTS_DIR-./config/vhosts}:/etc/apache2/sites-enabled
      - ${LOG_DIR-./logs/apache2}:/var/log/apache2
    networks:
      vpcbr:
        ipv4_address: 10.5.0.5

  mysql:
    build: ./bin/mysql
    container_name: 'png-mysql'
    restart: 'always'
    ports:
      - "3306:3306"
    volumes:
      - /var/www/docker-compose-lamp/bin/mysql/db:/docker-entrypoint-initdb.d
      - ${MYSQL_DATA_DIR-./data/mysql}:/var/lib/mysql
      - ${MYSQL_LOG_DIR-./logs/mysql}:/var/log/mysql
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: ivacy_muti_site
      MYSQL_USER: root
      MYSQL_PASSWORD: password
    networks:
      vpcbr:
        ipv4_address: 10.5.0.6
    depends_on:
     - mysql

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: 'png-phpmyadmin'
    links:
      - mysql
    environment:
      PMA_HOST: mysql
      PMA_PORT: 3306
    ports:
      - '8081:81'
    volumes: 
      - /sessions
    networks:
      vpcbr:
        ipv4_address: 10.5.0.7
    depends_on:
     - mysql
     - webserver

  redis:
    container_name: 'png-redis'
    image: redis:latest
    ports:
      - "6379:6379"
    networks:
      vpcbr:
        ipv4_address: 10.5.0.8
  networks:
    vpcbr:
      driver: bridge
      ipam:
       config:
         - subnet: 10.5.0.0/16
           gateway: 10.5.0.1

2 个答案:

答案 0 :(得分:1)

您已将networks缩进了服务块。

答案 1 :(得分:1)

网络应处于版本级别

version: '3.8'
services:
  web:
    build:
      args:
        version: 0.0.1
      context: .
      dockerfile: Dockerfile
    networks:
      - back-tier
    expose:
      - 8080
    ports:
    - 8080:8080
networks:
  back-tier:
    driver: bridge