Home > Enterprise >  docker-compose yaml file syntax issues
docker-compose yaml file syntax issues

Time:09-22

No matter what I try I keep getting syntax errors (mapping not allowed, or can not fine expected ":") on line 67 external: true ( (volumes section at the end). Can someone help me out with the format please? I have tried using quotes, tried messing with indentions and spacing etc, and no matter what I get an error. Thanks!!

# docker-compose.yml
version: '3.7'
services:
  jenkins:
    image: jenkins/jenkins:lts
    restart: always
    privileged: true
    user: root
    ports:
      - 8080:8080
      - 50000:50000
    container_name: jenkins
    volumes:
      - jenkins-data:/var/jenkins_home
      - /var/run/docker.sock:/var/run/docker.sock
  grafana:
    image: grafana/grafana:latest
    restart: always
    privileged: true
    user: root
    ports:
      - 8082:8082
    container_name: grafana
    volumes:
      - grafana-data:/var//lib/grafana
  nexus:
    image: sonatype/nexus3:latest
    restart: always
    privileged: true
    user: root
    ports:
      - 8081:8081
    container_name: nexus
    volumes:
      - nexus-data:/nexus-data
  gitlab:
    image: gitlab/gitlab-ee:latest
    restart: always
    privileged: true
    user: root
    ports:
      - 8083:8083
      - 443:8443
    container_name: gitlab
    volumes:
      - gitlab-data:/var/opt/gitlab
      - gitlab-config:/etc/gitlab
      - gitlab-logs:/var/logs/gitlab
  maven:
    image: maven:latest
    privileged: true
    user: root
    ports:
      - 8085:8085
    container_name: maven
    volumes:
      - maven-data:/root/.m2
  gradle:
    image: gradle:latest
    privileged: true
    user: root
    ports:
      - 8084:8084
    container_name: gradle
volumes:
  ec2-user_jenkins-data
        external: true
  ec2-user_jenkins-docker-certs
        external: true
  gitlab-config
        external: true
  gitlab-data
        external: true
  gitlab-logs
        external: true
  grafana-data
        external: true
  maven-data
        external: true
  sonarqube-data
        external: true
  sonarqube-config
        external: true

CodePudding user response:

I think you are just missing the ":" after volumes.

Here is the updated compose file.

# docker-compose.yml
version: '3.7'
services:
  jenkins:
    image: jenkins/jenkins:lts
    restart: always
    privileged: true
    user: root
    ports:
      - 8080:8080
      - 50000:50000
    container_name: jenkins
    volumes:
      - jenkins-data:/var/jenkins_home
      - /var/run/docker.sock:/var/run/docker.sock
  grafana:
    image: grafana/grafana:latest
    restart: always
    privileged: true
    user: root
    ports:
      - 8082:8082
    container_name: grafana
    volumes:
      - grafana-data:/var//lib/grafana
  nexus:
    image: sonatype/nexus3:latest
    restart: always
    privileged: true
    user: root
    ports:
      - 8081:8081
    container_name: nexus
    volumes:
      - nexus-data:/nexus-data
  gitlab:
    image: gitlab/gitlab-ee:latest
    restart: always
    privileged: true
    user: root
    ports:
      - 8083:8083
      - 443:8443
    container_name: gitlab
    volumes:
      - gitlab-data:/var/opt/gitlab
      - gitlab-config:/etc/gitlab
      - gitlab-logs:/var/logs/gitlab
  maven:
    image: maven:latest
    privileged: true
    user: root
    ports:
      - 8085:8085
    container_name: maven
    volumes:
      - maven-data:/root/.m2
  gradle:
    image: gradle:latest
    privileged: true
    user: root
    ports:
      - 8084:8084
    container_name: gradle
volumes:
  ec2-user_jenkins-data:
        external: true
  ec2-user_jenkins-docker-certs:
        external: true
  gitlab-config:
        external: true
  gitlab-data:
        external: true
  gitlab-logs:
       external: true
  grafana-data:
        external: true
  maven-data:
        external: true
  sonarqube-data:
        external: true
  sonarqube-config:
        external: true

Hope this helps :D

  • Related