Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从网络访问Docker Gitlab实例_Docker_Networking_Docker Compose_Gitlab - Fatal编程技术网

从网络访问Docker Gitlab实例

从网络访问Docker Gitlab实例,docker,networking,docker-compose,gitlab,Docker,Networking,Docker Compose,Gitlab,我正在本地网络的服务器计算机上安装一个带有docker compose的Gitlab实例,我希望通过访问例如“”,从本地网络的任何位置访问我的Gitlab实例 我跟着 我正在跑步: web: image: 'gitlab/gitlab-ce:latest' restart: always hostname: 'gitlab.example.com' environment: GITLAB_OMNIBUS_CONFIG: | external_url 'http

我正在本地网络的服务器计算机上安装一个带有docker compose的Gitlab实例,我希望通过访问例如“”,从本地网络的任何位置访问我的Gitlab实例

我跟着

我正在跑步:

web:
  image: 'gitlab/gitlab-ce:latest'
  restart: always
  hostname: 'gitlab.example.com'
  environment:
    GITLAB_OMNIBUS_CONFIG: |
      external_url 'https://gitlab.example.com'
      # Add any other gitlab.rb configuration here, each on its own line
  ports:
    - '7780:80'
    - '7443:443'
    - '7722:22'
  volumes:
    - '/srv/gitlab/config:/etc/gitlab'
    - '/srv/gitlab/logs:/var/log/gitlab'
    - '/srv/gitlab/data:/var/opt/gitlab'
 LOCAL NETWORK
 +--------------------------------------------------------------------------+
 |                                                                          |
 |   +--------------------+                                                 |
 |   |     My_Server      |                                                 |
 |   |                    |                                                 |
 |   | +----------------+ |                                                 |
 |   | |                | |  "https://my-hostname" +-------------------+    |
 |   | | Docker: Gitlab | <------------------------+     My_Client     |    |
 |   | |                | |                        +-------------------+    |
 |   | +----------------+ |                                                 |
 |   |                    |                                                 |
 |   +--------------------+                                                 |
 |                                                                          |
 +--------------------------------------------------------------------------+
现在我的网络知识非常(非常)有限,所以基本上,我如何访问正在运行的gitlab实例?当我转到主机的本地网络IP时,我的浏览器告诉我它无法连接

以下是我希望实现的目标:

web:
  image: 'gitlab/gitlab-ce:latest'
  restart: always
  hostname: 'gitlab.example.com'
  environment:
    GITLAB_OMNIBUS_CONFIG: |
      external_url 'https://gitlab.example.com'
      # Add any other gitlab.rb configuration here, each on its own line
  ports:
    - '7780:80'
    - '7443:443'
    - '7722:22'
  volumes:
    - '/srv/gitlab/config:/etc/gitlab'
    - '/srv/gitlab/logs:/var/log/gitlab'
    - '/srv/gitlab/data:/var/opt/gitlab'
 LOCAL NETWORK
 +--------------------------------------------------------------------------+
 |                                                                          |
 |   +--------------------+                                                 |
 |   |     My_Server      |                                                 |
 |   |                    |                                                 |
 |   | +----------------+ |                                                 |
 |   | |                | |  "https://my-hostname" +-------------------+    |
 |   | | Docker: Gitlab | <------------------------+     My_Client     |    |
 |   | |                | |                        +-------------------+    |
 |   | +----------------+ |                                                 |
 |   |                    |                                                 |
 |   +--------------------+                                                 |
 |                                                                          |
 +--------------------------------------------------------------------------+
本地网络
+--------------------------------------------------------------------------+
|                                                                          |
|   +--------------------+                                                 |
||我的服务器||
|   |                    |                                                 |
|   | +----------------+ |                                                 |
|   | |                | |  "https://my-hostname" +-------------------+    |

|| | Docker:Gitlab |配置的
端口
部分将主机端口映射到容器的端口

所以如果你有

端口: - '7780:80' - '7443:443' -‘7722:22’


这就是将主机上的端口7780重定向到容器上的端口80,以此类推。您应该能够访问容器的服务(通过其本地IP地址,然后通过本地DNS访问其主机名)。

对于初学者,您需要将
外部url
更改为您的外部url(例如
https://my-hostname
)。