skip to Main Content

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

2

Answers


  1. try a space at line 11: – net instead of -net

    Login or Signup to reply.
  2. 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 .

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search