简体   繁体   中英

What is wrong with this docker-compose.yml file

I am trying to install gitlab ce with docker compose file. I have had lots of permissions problem with bind volumes. I would like to try names volumes. Following is my file.

web:
  image: 'gitlab/gitlab-ce:latest'
  container_name: 'gitlab'
  restart: always
  hostname: 'gitlab.xxxx.com'
  environment:
    GITLAB_OMNIBUS_CONFIG: |
      external_url 'https://gitlab.xxxx.com'
  ports:
    - '10080:80'
    - '10443:443'
    - '10022:22'
  volumes:
    - gitlab_config:/etc/gitlab
    - gitlab_log:/var/log/gitlab
    - gitlab_data:/var/opt/gitlab
volumes: 
  gitlab_config:
    external: true
  gitlab_log: 
    external: true
  gitlab_data:
    external: true

I receive following error:

docker-compose up -d
ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for volumes: 'gitlab_data'

Volumes have been created previously with docker volume create command

UPDATE: Based the solution by Ganesh Satpute, I submit the working/tested file below. Someone may need it since gitlab page does not provide it. Thank you "Ganesh".

---
version: "2.4"
services:
  web:
    image: 'gitlab/gitlab-ce:latest'
    container_name: 'gitlab'
    restart: always
    hostname: 'gitlab.xxxx.com'
    environment:
       GITLAB_OMNIBUS_CONFIG: 'https://gitlab.xxxx.com'
    ports:
      - '10080:80'
      - '10443:443'
      - '10022:22'
    volumes:
      - gitlab_config:/etc/gitlab
      - gitlab_log:/var/log/gitlab
      - gitlab_data:/var/opt/gitlab
volumes: 
  gitlab_config:
    external: true
  gitlab_log:
    external: true
  gitlab_data:
    external: true

I modified your docker-compose.yml with this

version: "2.4"
services:
  web:
    image: 'gitlab/gitlab-ce:latest'
    container_name: 'gitlab'
    restart: always
    hostname: 'gitlab.xxxx.com'
    environment:
      GITLAB_OMNIBUS_CONFIG: 'https://gitlab.xxxx.com'
    ports:
    - '10080:80'
    - '10443:443'
    - '10022:22'
    volumes:
    - gitlab_config:/etc/gitlab
    - gitlab_log:/var/log/gitlab
    - gitlab_data:/var/opt/gitlab
volumes:
  gitlab_config:
    external: true
  gitlab_log:
    external: true
  gitlab_data:
    external: true

You can always check by running docker-compose config to check if the config file is valid or not. If not google the errors and also check few examples online.

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