Home > other >  Can't run the docker compose file
Can't run the docker compose file

Time:06-12

Can somebody, please, help me to understand what's wrong with my docker-compose.yml file?

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

I get an error:

ERROR: yaml.parser.ParserError: while parsing a block mapping
in "./docker-compose.yml", line 1, column 1
expected <block end>, but found '<block mapping start>'
in "./docker-compose.yml", line 2, column 3

CodePudding user response:

Try the following. There seem to be multiple issues with your compose file.

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

Note: If the following doesn't work, share the full docker-compose.yaml and the Docker compose version.

CodePudding user response:

You should indent lines after services, so the correct form is:

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