I have a file docker-compose.ymlthat starts a simple HTTP echo service on a port 8800.
version: '2'
services:
echo-server:
image: luisbebop/echo-server
container_name: echo-server
ports:
- "8800:8800"
Super simple stuff. If I run docker-compose upand run on my local computer:
echo "Hello World" | nc 127.0.0.1 8800
Then I see an echo. However: If I run the same build script inside the docker container through the GitLab runner, it does not work.
I tried to draw attention to this issue in GitLab, but with limited results: https://gitlab.com/gitlab-org/gitlab-ce/issues/26566
My .gitlab-ci.ymlfile looks like this:
stages:
- docker_test
services:
- docker:dind
docker_test:
stage: docker_test
image: docker:latest
script:
- docker version
- apk update
- apk add py-pip
- pip install docker-compose
- docker-compose up -d
- sleep 10
- netstat -tulpn
- docker-compose port echo-server 8800
- echo "Hello world" | nc 127.0.0.1 8800
And the conclusion gitlab-ci-multi-runner exec docker --docker-privileged docker_test:
$ netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
$ docker-compose port echo-server 8800
0.0.0.0:8800
$ echo "Hello world" | nc 127.0.0.1 8800
ERROR: Build failed: exit code 1
, , , -. - ?
, , , , , , .
Host (My Mac) -> GitLab CI Container -> Docker Compose Container exposing 8800
^ Not here ^ I want port 8800 accessible here
: , CI, :
/
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ab192edf5872 luisbebop/echo-server "/opt/echo-server/..." 2 minutes ago Up About a minute 0.0.0.0:8800->8800/tcp echo-server
/
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
"" , , .