skip to Main Content

I have the following docker-compose file and getting this error,

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

Answers


  1. You’ve indented networks into the services block.

    Login or Signup to reply.
  2. networks should be at version level

    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
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search