简体   繁体   中英

ERROR: The Compose file './docker-compose.yml' is invalid because: services.jenkins.networks contains an invalid type

ERROR: The Compose file './docker-compose.yml' is invalid because: services.jenkins.networks contains an invalid type, it should be an array, or an object

version: '3'
services:
  jenkins:
    container_name: jenkins
    image: jenkins
    ports:
      - "8080:8080"
    volumes:
      - "$PWD/jenkins_home:/var/jenkins_home"
    networks:
      -net
networks:
  net:

Docker-Compose - 1.26.0, build d4451659 || Jenkins for docker - Official Image || Linux Type - Cent-OS 7 minimal launched on AWS

try a space at line 11: - net instead of -net

using aliases would make your life easier.

version: '3.5'
services:

      jenkins-server:
    .
    .
    .
        networks:
          jenkins:
            aliases:
              - jenkins

at the bottom of the file making the network external would also keep the network when you do docker-compose down:

networks:
  jenkins:
    external: true

@aiman09 is also right about the space. Yml is very rigid with spaces.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM