将docker run命令转换为docker compose

时间:2016-03-23 03:31:54

标签: docker gitlab docker-compose gitlab-omnibus

我在这里失去了一点思绪,我想我已经正确翻译了这个命令,但是当我尝试docker-compose up -d

时我收到了错误

这是我的命令,这是有效的 - 没有失败:

sudo docker run -i \
    --hostname localhost \
    --publish 444:443 --publish 8080:8080 --publish 23:22 \
    --name gitlab \
    --restart always \
    --volume /home/admin/gitlab/config:/etc/gitlab \
    --volume /home/admin/gitlab/logs:/var/log/gitlab \
    --volume /home/admin/gitlab/data:/var/opt/gitlab \
    --volume /home/admin/gitlab/logs/reconfigure:/var/log/gitlab/reconfigure \
    -e VIRTUAL_HOST=git.example.com
    -e VIRTUAL_PORT=8080
gitlab/gitlab-ce:latest

这是我的docker-compose.yml文件,它不起作用

gitlab:
  image: 'gitlab/gitlab-ce:latest'
  restart: always
  container_name: gitlab
  ports:
    - '8080:80'
    - '23:22'
    - '444:443'
  volumes:
    - '/home/admin/gitlab/config:/etc/gitlab'
    - '/home/admin/gitlab/logs:/var/log/gitlab'
    - '/home/admin/gitlab/data:/var/opt/gitlab'
    - '/home/admin/gitlab/logs/reconfigure:/var/log/gitlab/reconfigure'
  environment:
    - VIRTUAL_HOST=git.example.ca
    - VIRTUAL_PORT=8080

你能看到我做错的事吗?

1 个答案:

答案 0 :(得分:1)

在docker run中添加hostname: localhost以获得

gitlab:
  image: 'gitlab/gitlab-ce:latest'
  restart: always
  container_name: gitlab
  hostname: localhost
  ports:
    - '8080:80'
    - '23:22'
    - '444:443'
  volumes:
    - '/home/admin/gitlab/config:/etc/gitlab'
    - '/home/admin/gitlab/logs:/var/log/gitlab'
    - '/home/admin/gitlab/data:/var/opt/gitlab'
    - '/home/admin/gitlab/logs/reconfigure:/var/log/gitlab/reconfigure'
  environment:
    - VIRTUAL_HOST=git.example.ca
    - VIRTUAL_PORT=8080