I am trying to setup test environment in Gitlab CI/CD. But starting PostgresContainer stuck forever.
[root@gitlab-runner ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f5813a178418 postgres:11.4-alpine "docker-entrypoint.s…" 9 minutes ago Up 9 minutes 0.0.0.0:32768->5432/tcp musing_khorana
[root@gitlab-runner-build-1 ~]# docker inspect f5813a178418
[
{
"Id": "f5813a1784187260cb46ee3f71edde72d189f00cc35308666a4df624a4bc680e",
"Created": "2020-04-15T05:22:14.043451232Z",
"Path": "docker-entrypoint.sh",
"Args": [
"postgres"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 271,
"ExitCode": 0,
"Error": "",
"StartedAt": "2020-04-15T05:22:14.631050518Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:5239fade3a90b73a10592a252289d6d916d050f39dafca0650ae14e878c23b0a",
"ResolvConfPath": "/var/lib/docker/containers/f5813a1784187260cb46ee3f71edde72d189f00cc35308666a4df624a4bc680e/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/f5813a1784187260cb46ee3f71edde72d189f00cc35308666a4df624a4bc680e/hostname",
"HostsPath": "/var/lib/docker/containers/f5813a1784187260cb46ee3f71edde72d189f00cc35308666a4df624a4bc680e/hosts",
"LogPath": "/var/lib/docker/containers/f5813a1784187260cb46ee3f71edde72d189f00cc35308666a4df624a4bc680e/f5813a1784187260cb46ee3f71edde72d189f00cc35308666a4df624a4bc680e-json.log",
"Name": "/musing_khorana",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {
"5432/tcp": [
{
"HostIp": "",
"HostPort": ""
}
]
},
"RestartPolicy": {
"Name": "",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Capabilities": null,
"Dns": null,
"DnsOptions": null,
"DnsSearch": null,
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "shareable",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": null,
"DeviceCgroupRules": null,
"DeviceRequests": null,
"KernelMemory": 0,
"KernelMemoryTCP": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/8c0f74be6b6273dfa92f746332d4c7b5a02183efa5bde3c40abf25f3329dbc59-init/diff:/var/lib/docker/overlay2/29efd662a010319d509a75483ff5650fa0ae46b41c98e374e4b3cc5e2c3e0167/diff:/var/lib/docker/overlay2/8723a0ffff99f7e5af3d94f9ebaaf155b9883836203690a908c64819718f8f66/diff:/var/lib/docker/overlay2/603fd62f94e002cdf27665e27b2ce6d0016da652eaf13838fcd66c0027c1171f/diff:/var/lib/docker/overlay2/fa06a053297fdcca4423d783ed6a8586bea4dd5aa9b9cb2631ad773f1cb1218d/diff:/var/lib/docker/overlay2/c72b4d9e0c149ec0062d2f8da3b23ff758ab58d0a55410e2c6697efe196ef9d8/diff:/var/lib/docker/overlay2/2a7c676edf9d77134aa92aa35b567935486e1efa37b13019f6ad6ce937824828/diff:/var/lib/docker/overlay2/bf218232ea043ee53d881f802b971e48327fd574505ed13b0be86cebbbd7f7a7/diff:/var/lib/docker/overlay2/fbd9de45ae6e8b7efc153206057e355beaf88899a462723c775db0b520fe882e/diff:/var/lib/docker/overlay2/903dc6646e74d53678e8d395df9bb080cceeb23bb945e628006d0650404dbdce/diff",
"MergedDir": "/var/lib/docker/overlay2/8c0f74be6b6273dfa92f746332d4c7b5a02183efa5bde3c40abf25f3329dbc59/merged",
"UpperDir": "/var/lib/docker/overlay2/8c0f74be6b6273dfa92f746332d4c7b5a02183efa5bde3c40abf25f3329dbc59/diff",
"WorkDir": "/var/lib/docker/overlay2/8c0f74be6b6273dfa92f746332d4c7b5a02183efa5bde3c40abf25f3329dbc59/work"
},
"Name": "overlay2"
},
"Mounts": [
{
"Type": "volume",
"Name": "60cdc4a7b03157ab2f14b66e4620480f24b2562912912ac9ed5305b439eb13a5",
"Source": "/var/lib/docker/volumes/60cdc4a7b03157ab2f14b66e4620480f24b2562912912ac9ed5305b439eb13a5/_data",
"Destination": "/var/lib/postgresql/data",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
],
"Config": {
"Hostname": "f5813a178418",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"5432/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"POSTGRES_USER=test",
"POSTGRES_PASSWORD=test",
"POSTGRES_DB=test",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"LANG=en_US.utf8",
"PG_MAJOR=11",
"PG_VERSION=11.4",
"PG_SHA256=02802ddffd1590805beddd1e464dd28a46a41a5f1e1df04bab4f46663195cc8b",
"PGDATA=/var/lib/postgresql/data"
],
"Cmd": [
"postgres"
],
"Image": "postgres:11.4-alpine",
"Volumes": {
"/var/lib/postgresql/data": {}
},
"WorkingDir": "",
"Entrypoint": [
"docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "a1dbb4c5bd2422ce0cffa574e1b44408c2aa7fbdef720d4ebd18bce550d9fe50",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"5432/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "32768"
}
]
},
"SandboxKey": "/var/run/docker/netns/a1dbb4c5bd24",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "6e8581cc476a339fb31a62df1a6acd6ae98e2bee101c713caffe1bb02a6318b8",
"Gateway": "172.18.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.18.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:12:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "8fe294d72eef7fd7fc47f6bad666ad0c70b395c3314b3a73545eac718c232b2e",
"EndpointID": "6e8581cc476a339fb31a62df1a6acd6ae98e2bee101c713caffe1bb02a6318b8",
"Gateway": "172.18.0.1",
"IPAddress": "172.18.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:12:00:02",
"DriverOpts": null
}
}
}
}
]
It seems to me that after starting the container, testcontainer tries to connect with container_ip:5432 rather than randomly generated docker_dind_host:32768. Without docker:dind, it works perfectly.