本文介绍了Hello World与在本地ubuntu上运行的gitlab ce docker容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的ubuntu笔记本电脑上本地运行gitlab社区版的docker映像.

I would like to run the docker image for gitlab community edition locally on my ubuntu laptop.

我正在关注本教程.

目前,我已经在本地主机上运行了另一个应用程序,因此我在docker -compose中更改了端口.

Currently there i already another app running on localhost so I changed the ports in docker -compose.

我现在拥有的是:我在一个名为'gitlab_test'的目录中.我已经按照指令 echo $ GITLAB_HOME/srv/gitlab 设置了全局变量.

What I currently have: I'm in a directory I created called 'gitlab_test'. I have set a global variable per the instructions echo $GITLAB_HOME /srv/gitlab.

我提取了ce gitlab映像 docker pull store/gitlab/gitlab-ce:11.10.4-ce.0

I pulled the ce gitlab image docker pull store/gitlab/gitlab-ce:11.10.4-ce.0

然后,在gitlab_test目录中,我添加了一个docker-compose文件:

Then, in the gitlab_test directory I added a docker-compose file:

web:
  image: 'gitlab/gitlab-ce:latest'
  restart: always
  hostname: 'localhost'
  environment:
    GITLAB_OMNIBUS_CONFIG: |
      external_url 'https://gitlab.example.com'
  ports:
    - '8080:8080'
    - '443:443'
    - '22:22'
  volumes:
    - '/srv/gitlab/config:/etc/gitlab'
    - '/srv/gitlab/logs:/var/log/gitlab'
    - '/srv/gitlab/data:/var/opt/gitlab'

我不确定是否需要在主机名和外部url参数中放置"localhost".我按原样尝试过,在每种情况下我都看不到任何事情发生.我期待在localhost:8080上使用gitlab的Web界面.

I am unsure if I need to put 'localhost' in place of hostname and external url parameters. I tried that and as is and in each case I cannot see anything happen. I was expecting a web interface for gitlab at localhost:8080.

尝试了 docker-compose up ,终端运行了一会儿,并显示了一堆输出.没有完成"消息(也许是因为我没有使用-d吗?),但是当我访问localhost:8080时,没有看到gitlab接口.

Tried docker-compose up and the terminal ran for a while with a bunch of output. There's no 'done' message (perhaps because I did not use -d?) but when I visit localhost:8080 I see no gitlab interface.

如何运行gitlab ce容器?

How can I run the gitlab ce container?

推荐答案

如果要使用其他端口,则不应更改容器端口".仅将容器端口暴露给的主机端口.因此,代替:

If you want to use different port you should not change your "container port". Only the host port you are exposing your container port to. So instead of:

  ports:
    - '8080:8080'
    - '443:443'
    - '22:22'

您应该这样做:

  ports:
    - '8080:80'
    - '443:443'
    - '22:22'

这意味着您将内部容器端口 80 (您无法更改)公开到主机端口 8080 .

Which means you expose the internal container port 80 (which you cannot change) to your host port 8080.

UPD::我是在本地启动此服务的,除了端口,我认为没有其他事情了.

UPD: I started this service locally and I think there are few things except ports to consider.

  1. 您应该创建 $ GITLAB_HOME 文件夹(这意味着不需要注册环境变量,而是创建专用文件夹集).您可以从示例中获取此'/srv/gitlab/config:/etc/gitlab',但这基本上意味着获取 srv/gitlab/config 的内容并将其安装到路径/etc/gitlab "在容器内.我相信主机上不存在像/srv/gitlab/config 这样的路径.
  2. 在帐户中考虑以上内容,我建议创建一个单独的文件夹(例如 my-gitlab )并创建文件夹 config logs data 放在该文件夹中.它们将为空,但将在Gitlab开始时填充.
  3. 将您的 docker-compose.yaml 放入 my-gitlab 并切换到该文件夹​​.
  4. 从该文件夹中
  5. 运行 docker-compose up .不要使用 -d 标志,这样您就不会分离并且可以查看是否发生错误.
  1. You should create $GITLAB_HOME folders (by this I mean that there is no need to register environment variable but rather to create set of dedicated folders). You take this '/srv/gitlab/config:/etc/gitlab' from example but this basically means "take content of srv/gitlab/config and mount it to the path /etc/gitlab" inside the container. I believe the paths like /srv/gitlab/config do not exist at your host.
  2. Taking the above in the account I would suggest to create a separate folder (say my-gitlab) and create the folders config, logs and data inside that folder. They are to be empty but will be filled on Gitlab start.
  3. Put your docker-compose.yaml to my-gitlab and switch to that folder.
  4. Run docker-compose up from that folder. Do not use -d flag so that you're not detaching and can see if errors happen.

下面是我的 docker-compose.yaml 并提供一些解释:

Below is my docker-compose.yaml with some explanation:

web:
  image: 'gitlab/gitlab-ce:latest'
  restart: always
  hostname: 'localhost'
  environment:
    GITLAB_OMNIBUS_CONFIG: |
      external_url 'http://localhost'
  ports:
    - '54321:80'
    - '54443:443'
    - '5422:22'
  volumes:
    - './config:/etc/gitlab'
    - './logs:/var/log/gitlab'
    - './data:/var/opt/gitlab'

说明:

  • 我的本地服务运行在 80 8080 22 443 上,因此我公开了所有移植到我目前有空的地方
  • 在这部分 http://localhost 中, http://很重要.如果您设置 https://,则Gitlab会尝试通过 Letsencrypt 为您的域请求SSL证书.为此,您必须具有公共域和某种端口配置.
  • 卷是通过.(当前目录)挂载的,因此具有一致的结构并从适当的位置调用 docker-compose up 非常重要.
  • I have my local services running at 80, 8080, 22 and 443 so I expose all the ports to what I have free by the moment
  • At this part http://localhost the http:// is important. If you set https:// Gitlab attempts to request SSL certificate for your domain at Letsencrypt. To make this you have to have public domain and some sort of port configuration.
  • Volumes are mounted through . (current directory) so that it is important to have consistent structure and call docker-compose up from a proper place.

因此,就我而言,我可以成功连接到 http://localhost:54321 .

So in my case I could successfully connect to http://localhost:54321.

这篇关于Hello World与在本地ubuntu上运行的gitlab ce docker容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 06:50