1 回答
TA貢獻(xiàn)1831條經(jīng)驗(yàn) 獲得超10個(gè)贊
在本地機(jī)器上運(yùn)行容器和在 GitLab 中運(yùn)行它們之間的重要區(qū)別之一docker:dind是容器在“本地主機(jī)”上不可用——它們?cè)赿ocker:dind容器上可用。
如果你想與這個(gè)容器交談,在你的場(chǎng)景中,postgres 容器將可用docker:5432(是你的 postgres 容器具有其端口映射docker的容器的主機(jī)名)。docker:dind
用簡(jiǎn)單的 HTTP 服務(wù)容器說明
作為一個(gè)簡(jiǎn)化的示例,如果您要strm/helloworld-http使用端口映射在本地運(yùn)行容器,則以下工作:
docker run -d --rm -p 80:80 strm/helloworld-http
# give it some time to startup
curl http://localhost # this works
但是,GitLab 中的相同設(shè)置不會(huì):
myjob:
variables: # these variables are not necessarily required
DOCKER_TLS_CERTDIR: ""
DOCKER_HOST: "tcp://docker:2375"
services:
- docker:dind
script:
- docker run -d --rm -p 80:80 strm/helloworld-http
- sleep 10
- curl http://localhost # Fails!
一種解決方法是改用docker主機(jī)名:
script:
- docker run -d --rm -p 80:80 strm/helloworld-http
- sleep 10
- curl http://docker # works!
- 1 回答
- 0 關(guān)注
- 171 瀏覽
添加回答
舉報(bào)
