<p>I fixed the issue. In my case, it was <code>PORT</code> (absolutely) and <code>HOST</code> (maybe) environment variables I defined manually in the GitLab CI/CD Variables section. It seems <code>PORT</code> and maybe <code>HOST</code> are two reserved environment variables for GitLab and/or Docker.</p>
<p>By the way, I couldn't find anything in docs state not using those variables names.</p>

CC BY-SA 4.0
2020-07-20T19:47:57.313Z
2020-07-20T19:47:57.313Z
Alex
<p><strong>GitLab Job Log</strong></p>
<pre><code>[0KRunning with gitlab-runner 13.2.0-rc2 (45f2b4ec)
[0;m[0K  on docker-auto-scale fa6cab46
[0;msection_start:1595233272:prepare_executor
[0K[0K[36;1mPreparing the &quot;docker+machine&quot; executor[0;m
[0;m[0KUsing Docker executor with image gitlab/dind:latest ...
[0;m[0KStarting service docker:dind ...
[0;m[0KPulling docker image docker:dind ...
[0;m[0KUsing docker image sha256:d5d139be840a6ffa04348fc87740e8c095cade6e9cb977785fdba51e5fd7ffec for docker:dind ...
[0;m[0KWaiting for services to be up and running...
[0;m
[0;33m*** WARNING:[0;m Service runner-fa6cab46-project-18378289-concurrent-0-31a688551619da9f-docker-0 probably didn't start properly.

Health check error:
service &quot;runner-fa6cab46-project-18378289-concurrent-0-31a688551619da9f-docker-0-wait-for-service&quot; timeout

Health check container logs:


Service container logs:
2020-07-20T08:21:19.734721788Z time=&quot;2020-07-20T08:21:19.734543379Z&quot; level=info msg=&quot;Starting up&quot;
2020-07-20T08:21:19.742928068Z time=&quot;2020-07-20T08:21:19.742802844Z&quot; level=warning msg=&quot;could not change group /var/run/docker.sock to docker: group docker not found&quot;
2020-07-20T08:21:19.743943014Z time=&quot;2020-07-20T08:21:19.743853574Z&quot; level=warning msg=&quot;[!] DON'T BIND ON ANY IP ADDRESS WITHOUT setting --tlsverify IF YOU DON'T KNOW WHAT YOU'RE DOING [!]&quot;
2020-07-20T08:21:19.764021012Z time=&quot;2020-07-20T08:21:19.763898078Z&quot; level=info msg=&quot;libcontainerd: started new containerd process&quot; pid=23
2020-07-20T08:21:19.764159337Z time=&quot;2020-07-20T08:21:19.764107864Z&quot; level=info msg=&quot;parsed scheme: \&quot;unix\&quot;&quot; module=grpc
2020-07-20T08:21:19.764207629Z time=&quot;2020-07-20T08:21:19.764179926Z&quot; level=info msg=&quot;scheme \&quot;unix\&quot; not registered, fallback to default scheme&quot; module=grpc
2020-07-20T08:21:19.764319635Z time=&quot;2020-07-20T08:21:19.764279612Z&quot; level=info msg=&quot;ccResolverWrapper: sending update to cc: {[{unix:///var/run/docker/containerd/containerd.sock 0  &lt;nil&gt;}] &lt;nil&gt;}&quot; module=grpc
2020-07-20T08:21:19.764371375Z time=&quot;2020-07-20T08:21:19.764344798Z&quot; level=info msg=&quot;ClientConn switching balancer to \&quot;pick_first\&quot;&quot; module=grpc
2020-07-20T08:21:19.969344247Z time=&quot;2020-07-20T08:21:19.969193121Z&quot; level=info msg=&quot;starting containerd&quot; revision=7ad184331fa3e55e52b890ea95e65ba581ae3429 version=v1.2.13 
2020-07-20T08:21:19.969863044Z time=&quot;2020-07-20T08:21:19.969784495Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.content.v1.content&quot;...&quot; type=io.containerd.content.v1 
2020-07-20T08:21:19.970042302Z time=&quot;2020-07-20T08:21:19.969997665Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.snapshotter.v1.btrfs&quot;...&quot; type=io.containerd.snapshotter.v1 
2020-07-20T08:21:19.970399514Z time=&quot;2020-07-20T08:21:19.970336671Z&quot; level=warning msg=&quot;failed to load plugin io.containerd.snapshotter.v1.btrfs&quot; error=&quot;path /var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.btrfs must be a btrfs filesystem to be used with the btrfs snapshotter&quot; 
2020-07-20T08:21:19.970474776Z time=&quot;2020-07-20T08:21:19.970428684Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.snapshotter.v1.aufs&quot;...&quot; type=io.containerd.snapshotter.v1 
2020-07-20T08:21:20.019585153Z time=&quot;2020-07-20T08:21:20.019421401Z&quot; level=warning msg=&quot;failed to load plugin io.containerd.snapshotter.v1.aufs&quot; error=&quot;modprobe aufs failed: &quot;ip: can't find device 'aufs'\nmodprobe: can't change directory to '/lib/modules': No such file or directory\n&quot;: exit status 1&quot; 
2020-07-20T08:21:20.019709540Z time=&quot;2020-07-20T08:21:20.019668899Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.snapshotter.v1.native&quot;...&quot; type=io.containerd.snapshotter.v1 
2020-07-20T08:21:20.019934319Z time=&quot;2020-07-20T08:21:20.019887606Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.snapshotter.v1.overlayfs&quot;...&quot; type=io.containerd.snapshotter.v1 
2020-07-20T08:21:20.020299876Z time=&quot;2020-07-20T08:21:20.020218529Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.snapshotter.v1.zfs&quot;...&quot; type=io.containerd.snapshotter.v1 
2020-07-20T08:21:20.021038477Z time=&quot;2020-07-20T08:21:20.020887571Z&quot; level=info msg=&quot;skip loading plugin &quot;io.containerd.snapshotter.v1.zfs&quot;...&quot; type=io.containerd.snapshotter.v1 
2020-07-20T08:21:20.021162370Z time=&quot;2020-07-20T08:21:20.021121663Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.metadata.v1.bolt&quot;...&quot; type=io.containerd.metadata.v1 
2020-07-20T08:21:20.021406797Z time=&quot;2020-07-20T08:21:20.021348536Z&quot; level=warning msg=&quot;could not use snapshotter aufs in metadata plugin&quot; error=&quot;modprobe aufs failed: &quot;ip: can't find device 'aufs'\nmodprobe: can't change directory to '/lib/modules': No such file or directory\n&quot;: exit status 1&quot; 
2020-07-20T08:21:20.021487917Z time=&quot;2020-07-20T08:21:20.021435946Z&quot; level=warning msg=&quot;could not use snapshotter zfs in metadata plugin&quot; error=&quot;path /var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.zfs must be a zfs filesystem to be used with the zfs snapshotter: skip plugin&quot; 
2020-07-20T08:21:20.021581245Z time=&quot;2020-07-20T08:21:20.021533539Z&quot; level=warning msg=&quot;could not use snapshotter btrfs in metadata plugin&quot; error=&quot;path /var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.btrfs must be a btrfs filesystem to be used with the btrfs snapshotter&quot; 
2020-07-20T08:21:20.030531741Z time=&quot;2020-07-20T08:21:20.030427430Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.differ.v1.walking&quot;...&quot; type=io.containerd.differ.v1 
2020-07-20T08:21:20.030639854Z time=&quot;2020-07-20T08:21:20.030604536Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.gc.v1.scheduler&quot;...&quot; type=io.containerd.gc.v1 
2020-07-20T08:21:20.030779501Z time=&quot;2020-07-20T08:21:20.030736875Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.service.v1.containers-service&quot;...&quot; type=io.containerd.service.v1 
2020-07-20T08:21:20.030865060Z time=&quot;2020-07-20T08:21:20.030833703Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.service.v1.content-service&quot;...&quot; type=io.containerd.service.v1 
2020-07-20T08:21:20.030955439Z time=&quot;2020-07-20T08:21:20.030912981Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.service.v1.diff-service&quot;...&quot; type=io.containerd.service.v1 
2020-07-20T08:21:20.031027842Z time=&quot;2020-07-20T08:21:20.030998003Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.service.v1.images-service&quot;...&quot; type=io.containerd.service.v1 
2020-07-20T08:21:20.031132325Z time=&quot;2020-07-20T08:21:20.031083782Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.service.v1.leases-service&quot;...&quot; type=io.containerd.service.v1 
2020-07-20T08:21:20.031202966Z time=&quot;2020-07-20T08:21:20.031174445Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.service.v1.namespaces-service&quot;...&quot; type=io.containerd.service.v1 
2020-07-20T08:21:20.031286993Z time=&quot;2020-07-20T08:21:20.031253528Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.service.v1.snapshots-service&quot;...&quot; type=io.containerd.service.v1 
2020-07-20T08:21:20.031370557Z time=&quot;2020-07-20T08:21:20.031312376Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.runtime.v1.linux&quot;...&quot; type=io.containerd.runtime.v1 
2020-07-20T08:21:20.031709756Z time=&quot;2020-07-20T08:21:20.031650044Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.runtime.v2.task&quot;...&quot; type=io.containerd.runtime.v2 
2020-07-20T08:21:20.031941868Z time=&quot;2020-07-20T08:21:20.031897088Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.monitor.v1.cgroups&quot;...&quot; type=io.containerd.monitor.v1 
2020-07-20T08:21:20.032929781Z time=&quot;2020-07-20T08:21:20.032846588Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.service.v1.tasks-service&quot;...&quot; type=io.containerd.service.v1 
2020-07-20T08:21:20.033064279Z time=&quot;2020-07-20T08:21:20.033014391Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.internal.v1.restart&quot;...&quot; type=io.containerd.internal.v1 
2020-07-20T08:21:20.034207198Z time=&quot;2020-07-20T08:21:20.034120505Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.grpc.v1.containers&quot;...&quot; type=io.containerd.grpc.v1 
2020-07-20T08:21:20.034316027Z time=&quot;2020-07-20T08:21:20.034279582Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.grpc.v1.content&quot;...&quot; type=io.containerd.grpc.v1 
2020-07-20T08:21:20.034402334Z time=&quot;2020-07-20T08:21:20.034369239Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.grpc.v1.diff&quot;...&quot; type=io.containerd.grpc.v1 
2020-07-20T08:21:20.034482782Z time=&quot;2020-07-20T08:21:20.034452282Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.grpc.v1.events&quot;...&quot; type=io.containerd.grpc.v1 
2020-07-20T08:21:20.034564724Z time=&quot;2020-07-20T08:21:20.034533365Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.grpc.v1.healthcheck&quot;...&quot; type=io.containerd.grpc.v1 
2020-07-20T08:21:20.034645756Z time=&quot;2020-07-20T08:21:20.034617060Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.grpc.v1.images&quot;...&quot; type=io.containerd.grpc.v1 
2020-07-20T08:21:20.034722695Z time=&quot;2020-07-20T08:21:20.034689037Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.grpc.v1.leases&quot;...&quot; type=io.containerd.grpc.v1 
2020-07-20T08:21:20.034800005Z time=&quot;2020-07-20T08:21:20.034770572Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.grpc.v1.namespaces&quot;...&quot; type=io.containerd.grpc.v1 
2020-07-20T08:21:20.034873069Z time=&quot;2020-07-20T08:21:20.034837050Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.internal.v1.opt&quot;...&quot; type=io.containerd.internal.v1 
2020-07-20T08:21:20.036608424Z time=&quot;2020-07-20T08:21:20.036525701Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.grpc.v1.snapshots&quot;...&quot; type=io.containerd.grpc.v1 
2020-07-20T08:21:20.036722927Z time=&quot;2020-07-20T08:21:20.036684403Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.grpc.v1.tasks&quot;...&quot; type=io.containerd.grpc.v1 
2020-07-20T08:21:20.036799326Z time=&quot;2020-07-20T08:21:20.036769392Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.grpc.v1.version&quot;...&quot; type=io.containerd.grpc.v1 
2020-07-20T08:21:20.036876692Z time=&quot;2020-07-20T08:21:20.036844684Z&quot; level=info msg=&quot;loading plugin &quot;io.containerd.grpc.v1.introspection&quot;...&quot; type=io.containerd.grpc.v1 
2020-07-20T08:21:20.037291381Z time=&quot;2020-07-20T08:21:20.037244979Z&quot; level=info msg=serving... address=&quot;/var/run/docker/containerd/containerd-debug.sock&quot; 
2020-07-20T08:21:20.037493736Z time=&quot;2020-07-20T08:21:20.037445814Z&quot; level=info msg=serving... address=&quot;/var/run/docker/containerd/containerd.sock&quot; 
2020-07-20T08:21:20.037563487Z time=&quot;2020-07-20T08:21:20.037522305Z&quot; level=info msg=&quot;containerd successfully booted in 0.069638s&quot; 
2020-07-20T08:21:20.087933162Z time=&quot;2020-07-20T08:21:20.087804902Z&quot; level=info msg=&quot;Setting the storage driver from the $DOCKER_DRIVER environment variable (overlay2)&quot;
2020-07-20T08:21:20.088415387Z time=&quot;2020-07-20T08:21:20.088327506Z&quot; level=info msg=&quot;parsed scheme: \&quot;unix\&quot;&quot; module=grpc
2020-07-20T08:21:20.088533804Z time=&quot;2020-07-20T08:21:20.088465157Z&quot; level=info msg=&quot;scheme \&quot;unix\&quot; not registered, fallback to default scheme&quot; module=grpc
2020-07-20T08:21:20.088620947Z time=&quot;2020-07-20T08:21:20.088562235Z&quot; level=info msg=&quot;ccResolverWrapper: sending update to cc: {[{unix:///var/run/docker/containerd/containerd.sock 0  &lt;nil&gt;}] &lt;nil&gt;}&quot; module=grpc
2020-07-20T08:21:20.088709546Z time=&quot;2020-07-20T08:21:20.088654016Z&quot; level=info msg=&quot;ClientConn switching balancer to \&quot;pick_first\&quot;&quot; module=grpc
2020-07-20T08:21:20.092857445Z time=&quot;2020-07-20T08:21:20.092749940Z&quot; level=info msg=&quot;parsed scheme: \&quot;unix\&quot;&quot; module=grpc
2020-07-20T08:21:20.092962469Z time=&quot;2020-07-20T08:21:20.092914347Z&quot; level=info msg=&quot;scheme \&quot;unix\&quot; not registered, fallback to default scheme&quot; module=grpc
2020-07-20T08:21:20.093060327Z time=&quot;2020-07-20T08:21:20.093013905Z&quot; level=info msg=&quot;ccResolverWrapper: sending update to cc: {[{unix:///var/run/docker/containerd/containerd.sock 0  &lt;nil&gt;}] &lt;nil&gt;}&quot; module=grpc
2020-07-20T08:21:20.093142744Z time=&quot;2020-07-20T08:21:20.093102173Z&quot; level=info msg=&quot;ClientConn switching balancer to \&quot;pick_first\&quot;&quot; module=grpc
2020-07-20T08:21:20.149109416Z time=&quot;2020-07-20T08:21:20.148965236Z&quot; level=info msg=&quot;Loading containers: start.&quot;
2020-07-20T08:21:20.159351905Z time=&quot;2020-07-20T08:21:20.159146135Z&quot; level=warning msg=&quot;Running modprobe bridge br_netfilter failed with message: ip: can't find device 'bridge'\nbridge                167936  1 br_netfilter\nstp                    16384  1 bridge\nllc                    16384  2 bridge,stp\nip: can't find device 'br_netfilter'\nbr_netfilter           24576  0 \nbridge                167936  1 br_netfilter\nmodprobe: can't change directory to '/lib/modules': No such file or directory\n, error: exit status 1&quot;
2020-07-20T08:21:20.280536391Z time=&quot;2020-07-20T08:21:20.280402152Z&quot; level=info msg=&quot;Default bridge (docker0) is assigned with an IP address 172.18.0.0/16. Daemon option --bip can be used to set a preferred IP address&quot;
2020-07-20T08:21:20.337028532Z time=&quot;2020-07-20T08:21:20.336889956Z&quot; level=info msg=&quot;Loading containers: done.&quot;
2020-07-20T08:21:20.435200532Z time=&quot;2020-07-20T08:21:20.435033092Z&quot; level=info msg=&quot;Docker daemon&quot; commit=48a66213fe graphdriver(s)=overlay2 version=19.03.12
2020-07-20T08:21:20.436386855Z time=&quot;2020-07-20T08:21:20.436266338Z&quot; level=info msg=&quot;Daemon has completed initialization&quot;
2020-07-20T08:21:20.476621441Z time=&quot;2020-07-20T08:21:20.475137317Z&quot; level=info msg=&quot;API listen on [::]:2375&quot;
2020-07-20T08:21:20.477679219Z time=&quot;2020-07-20T08:21:20.477535808Z&quot; level=info msg=&quot;API listen on /var/run/docker.sock&quot;

[0;33m*********[0;m

[0KPulling docker image gitlab/dind:latest ...
[0;m[0KUsing docker image sha256:cc674e878f23bdc3c36cc37596d31adaa23bca0fc3ed18bea9b59abc638602e1 for gitlab/dind:latest ...
[0;msection_end:1595233326:prepare_executor
[0Ksection_start:1595233326:prepare_script
[0K[0K[36;1mPreparing environment[0;m
[0;mRunning on runner-fa6cab46-project-18378289-concurrent-0 via runner-fa6cab46-srm-1595233216-1bd30100...
section_end:1595233330:prepare_script
[0Ksection_start:1595233330:get_sources
[0K[0K[36;1mGetting source from Git repository[0;m
[0;m[32;1m$ eval &quot;$CI_PRE_CLONE_SCRIPT&quot;[0;m
[32;1mFetching changes with git depth set to 50...[0;m
Initialized empty Git repository in /builds/xxx.us/backend/.git/
[32;1mCreated fresh repository.[0;m
[32;1mChecking out 257ffdf2 as stage...[0;m

[32;1mSkipping Git submodules setup[0;m
section_end:1595233333:get_sources
[0Ksection_start:1595233333:restore_cache
[0K[0K[36;1mRestoring cache[0;m
[0;m[32;1mChecking cache for stage node:14.5.0-alpine-2...[0;m
Downloading cache.zip from https://storage.googleapis.com/gitlab-com-runners-cache/project/18378289/stage%20node:14.5.0-alpine-2[0;m 
[32;1mSuccessfully extracted cache[0;m
section_end:1595233334:restore_cache
[0Ksection_start:1595233334:step_script
[0K[0K[36;1mExecuting &quot;step_script&quot; stage of the job script[0;m
[0;mln: failed to create symbolic link '/sys/fs/cgroup/systemd/name=systemd': Operation not permitted
time=&quot;2020-07-20T08:22:14.844844859Z&quot; level=warning msg=&quot;[!] DON'T BIND ON ANY IP ADDRESS WITHOUT setting -tlsverify IF YOU DON'T KNOW WHAT YOU'RE DOING [!]&quot; 
time=&quot;2020-07-20T08:22:14.846663310Z&quot; level=info msg=&quot;libcontainerd: new containerd process, pid: 57&quot; 
time=&quot;2020-07-20T08:22:14.906788853Z&quot; level=info msg=&quot;Graph migration to content-addressability took 0.00 seconds&quot; 
time=&quot;2020-07-20T08:22:14.907996055Z&quot; level=info msg=&quot;Loading containers: start.&quot; 
time=&quot;2020-07-20T08:22:14.910877638Z&quot; level=warning msg=&quot;Running modprobe bridge br_netfilter failed with message: modprobe: ERROR: ../libkmod/libkmod.c:556 kmod_search_moddep() could not open moddep file '/lib/modules/4.19.78-coreos/modules.dep.bin'\nmodprobe: ERROR: ../libkmod/libkmod.c:556 kmod_search_moddep() could not open moddep file '/lib/modules/4.19.78-coreos/modules.dep.bin'\n, error: exit status 1&quot; 
time=&quot;2020-07-20T08:22:14.912665866Z&quot; level=warning msg=&quot;Running modprobe nf_nat failed with message: `modprobe: ERROR: ../libkmod/libkmod.c:556 kmod_search_moddep() could not open moddep file '/lib/modules/4.19.78-coreos/modules.dep.bin'`, error: exit status 1&quot; 
time=&quot;2020-07-20T08:22:14.914201302Z&quot; level=warning msg=&quot;Running modprobe xt_conntrack failed with message: `modprobe: ERROR: ../libkmod/libkmod.c:556 kmod_search_moddep() could not open moddep file '/lib/modules/4.19.78-coreos/modules.dep.bin'`, error: exit status 1&quot; 
time=&quot;2020-07-20T08:22:14.989456423Z&quot; level=warning msg=&quot;Could not load necessary modules for IPSEC rules: Running modprobe xfrm_user failed with message: `modprobe: ERROR: ../libkmod/libkmod.c:556 kmod_search_moddep() could not open moddep file '/lib/modules/4.19.78-coreos/modules.dep.bin'`, error: exit status 1&quot; 
time=&quot;2020-07-20T08:22:14.990108153Z&quot; level=info msg=&quot;Default bridge (docker0) is assigned with an IP address 172.18.0.0/16. Daemon option --bip can be used to set a preferred IP address&quot; 

time=&quot;2020-07-20T08:22:15.029286773Z&quot; level=info msg=&quot;Loading containers: done.&quot; 
time=&quot;2020-07-20T08:22:15.029664106Z&quot; level=info msg=&quot;Daemon has completed initialization&quot; 
time=&quot;2020-07-20T08:22:15.029823541Z&quot; level=info msg=&quot;Docker daemon&quot; commit=23cf638 graphdriver=overlay2 version=1.12.1 
time=&quot;2020-07-20T08:22:15.048665494Z&quot; level=info msg=&quot;API listen on /var/run/docker.sock&quot; 
time=&quot;2020-07-20T08:22:15.049046558Z&quot; level=info msg=&quot;API listen on [::]:7070&quot; 

# Keeps loading and finally fails after a couple of seconds
</code></pre>
<p><strong>gitlab-ci.yml</strong></p>
<pre><code>cache:
  key: '$CI_COMMIT_REF_NAME node:14.5.0-alpine'
  paths:
    - node_modules/

stages:
  - release
  - deploy

variables:
  TAGGED_IMAGE: '$CI_REGISTRY_IMAGE:latest'

.release:
  stage: release
  image: docker:19.03.12
  services:
    - docker:dind
  variables:
    DOCKER_DRIVER: overlay2
    DOCKER_BUILDKIT: 1
  before_script:
    - docker version
    - docker info
    - echo &quot;$CI_JOB_TOKEN&quot; | docker login --username $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
  script:
    - docker build --pull --tag $TAGGED_IMAGE --cache-from $TAGGED_IMAGE --build-arg NODE_ENV=$CI_ENVIRONMENT_NAME .
    - docker push $TAGGED_IMAGE
  after_script:
    - docker logout $CI_REGISTRY

.deploy:
  stage: deploy
  image: gitlab/dind:latest
  services:
    - docker:dind
  variables:
    DOCKER_COMPOSE_PATH: '~/docker-composes/$CI_PROJECT_PATH/docker-compose.yml'
  before_script:
    - 'which ssh-agent || ( apt-get update -y &amp;&amp; apt-get install openssh-client -y )'
    - eval $(ssh-agent -s)
    - echo &quot;$DEPLOY_SERVER_PRIVATE_KEY&quot; | tr -d '\r' | ssh-add -
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - ssh-keyscan $DEPLOYMENT_SERVER_IP &gt;&gt; ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
  script:
    - rsync -avR --rsync-path=&quot;mkdir -p ~/docker-composes/$CI_PROJECT_PATH/; rsync&quot; ./docker-compose.yml root@$DEPLOYMENT_SERVER_IP:~/docker-composes/$CI_PROJECT_PATH/
    - ssh root@$DEPLOYMENT_SERVER_IP &quot;echo &quot;$CI_REGISTRY_PASSWORD&quot; | docker login --username $CI_REGISTRY_USER --password-stdin $CI_REGISTRY; docker-compose -f $DOCKER_COMPOSE_PATH rm -f -s -v $CI_COMMIT_REF_NAME; docker pull $TAGGED_IMAGE; docker-compose -f $DOCKER_COMPOSE_PATH up -d $CI_COMMIT_REF_NAME;&quot;

release_stage:
  extends: .release
  only:
    - stage
  environment:
    name: staging

deploy_stage:
  extends: .deploy
  only:
    - stage
  environment:
    name: staging
</code></pre>
<p><strong>Dockerfile</strong></p>
<pre><code>ARG NODE_ENV

FROM node:14.5.0-alpine

ARG NODE_ENV

ENV NODE_ENV ${NODE_ENV}

# Set working directory
WORKDIR /var/www/

# Install app dependencies
COPY package.json package-lock.json ./
RUN npm ci --silent --only=production

COPY . ./

# Start the application
CMD [ &quot;npm&quot;, &quot;run&quot;, &quot;start&quot; ]
</code></pre>
<p><strong>docker-compose.yml</strong></p>
<pre><code>version: '3.8'

services:
  redis-stage:
    container_name: redis-stage
    image: redis:6.0.5-alpine
    ports:
      - '7075:6379'
    restart: always
    networks:
      - my-proxy-net

  stage:
    container_name: xxx-backend-stage
    image: registry.gitlab.com/xxx.us/backend:latest
    build: .
    expose:
      - '7070'
    restart: always
    networks:
      - my-proxy-net
    depends_on:
      - redis-stage
    environment:
      VIRTUAL_HOST: backend.xxx.us
      VIRTUAL_PROTO: https
      LETSENCRYPT_HOST: backend.xxx.us

networks:
  my-proxy-net:
    external:
      name: mynetwork
</code></pre>
<p><strong>Update 1</strong></p>
<p>I got a warning on the page claims I have used over 30% of my shared runner minutes. Maybe it is about not having enough minutes.</p>
<p><strong>Update 2</strong></p>
<p>The <code>release</code> stage gets completed successfully.</p>
<p><strong>Update 3</strong></p>
<p>Before I get into this problem, I deployed once successfully. I decided to test that commit once again and see if it succeeds, but it fails!</p>

<docker><docker-compose><gitlab><cicd><node.js>
GitLab keeps loading and finally fails when deploying a dockerized node.js app
Alex
# GitLab keeps loading and finally fails when deploying a dockerized node.js app

(Asked by: username_0 on 2020-07-20)

GitLab Job Log
[0KRunning with gitlab-runner 13.2.0-rc2 (45f2b4ec)
[0;m[0K  on docker-auto-scale fa6cab46
[0;msection_start:1595233272:prepare_executor
[0K[0K[36;1mPreparing the "docker+machine" executor[0;m
[0;m[0KUsing Docker executor with image gitlab/dind:latest ...
[0;m[0KStarting service docker:dind ...
[0;m[0KPulling docker image docker:dind ...
[0;m[0KUsing docker image sha256:d5d139be840a6ffa04348fc87740e8c095cade6e9cb977785fdba51e5fd7ffec for docker:dind ...
[0;m[0KWaiting for services to be up and running...
[0;m
[0;33m*** WARNING:[0;m Service runner-fa6cab46-project-18378289-concurrent-0-31a688551619da9f-docker-0 probably didn't start properly.

Health check error:
service "runner-fa6cab46-project-18378289-concurrent-0-31a688551619da9f-docker-0-wait-for-service" timeout

Health check container logs:


Service container logs:
2020-07-20T08:21:19.734721788Z time="2020-07-20T08:21:19.734543379Z" level=info msg="Starting up"
2020-07-20T08:21:19.742928068Z time="2020-07-20T08:21:19.742802844Z" level=warning msg="could not change group /var/run/docker.sock to docker: group docker not found"
2020-07-20T08:21:19.743943014Z time="2020-07-20T08:21:19.743853574Z" level=warning msg="[!] DON'T BIND ON ANY IP ADDRESS WITHOUT setting --tlsverify IF YOU DON'T KNOW WHAT YOU'RE DOING [!]"
2020-07-20T08:21:19.764021012Z time="2020-07-20T08:21:19.763898078Z" level=info msg="libcontainerd: started new containerd process" pid=23
2020-07-20T08:21:19.764159337Z time="2020-07-20T08:21:19.764107864Z" level=info msg="parsed scheme: \"unix\"" module=grpc
2020-07-20T08:21:19.764207629Z time="2020-07-20T08:21:19.764179926Z" level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc
2020-07-20T08:21:19.764319635Z time="2020-07-20T08:21:19.764279612Z" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///var/run/docker/containerd/containerd.sock 0  }] }" module=grpc
2020-07-20T08:21:19.764371375Z time="2020-07-20T08:21:19.764344798Z" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
2020-07-20T08:21:19.969344247Z time="2020-07-20T08:21:19.969193121Z" level=info msg="starting containerd" revision=7ad184331fa3e55e52b890ea95e65ba581ae3429 version=v1.2.13 
2020-07-20T08:21:19.969863044Z time="2020-07-20T08:21:19.969784495Z" level=info msg="loading plugin "io.containerd.content.v1.content"..." type=io.containerd.content.v1 
2020-07-20T08:21:19.970042302Z time="2020-07-20T08:21:19.969997665Z" level=info msg="loading plugin "io.containerd.snapshotter.v1.btrfs"..." type=io.containerd.snapshotter.v1 
2020-07-20T08:21:19.970399514Z time="2020-07-20T08:21:19.970336671Z" level=warning msg="failed to load plugin io.containerd.snapshotter.v1.btrfs" error="path /var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.btrfs must be a btrfs filesystem to be used with the btrfs snapshotter" 
2020-07-20T08:21:19.970474776Z time="2020-07-20T08:21:19.970428684Z" level=info msg="loading plugin "io.containerd.snapshotter.v1.aufs"..." type=io.containerd.snapshotter.v1 
2020-07-20T08:21:20.019585153Z time="2020-07-20T08:21:20.019421401Z" level=warning msg="failed to load plugin io.containerd.snapshotter.v1.aufs" error="modprobe aufs failed: "ip: can't find device 'aufs'\nmodprobe: can't change directory to '/lib/modules': No such file or directory\n": exit status 1" 
2020-07-20T08:21:20.019709540Z time="2020-07-20T08:21:20.019668899Z" level=info msg="loading plugin "io.containerd.snapshotter.v1.native"..." type=io.containerd.snapshotter.v1 
2020-07-20T08:21:20.019934319Z time="2020-07-20T08:21:20.019887606Z" level=info msg="loading plugin "io.containerd.snapshotter.v1.overlayfs"..." type=io.containerd.snapshotter.v1 
2020-07-20T08:21:20.020299876Z time="2020-07-20T08:21:20.020218529Z" level=info msg="loading plugin "io.containerd.snapshotter.v1.zfs"..." type=io.containerd.snapshotter.v1 
2020-07-20T08:21:20.021038477Z time="2020-07-20T08:21:20.020887571Z" level=info msg="skip loading plugin "io.containerd.snapshotter.v1.zfs"..." type=io.containerd.snapshotter.v1 
2020-07-20T08:21:20.021162370Z time="2020-07-20T08:21:20.021121663Z" level=info msg="loading plugin "io.containerd.metadata.v1.bolt"..." type=io.containerd.metadata.v1 
2020-07-20T08:21:20.021406797Z time="2020-07-20T08:21:20.021348536Z" level=warning msg="could not use snapshotter aufs in metadata plugin" error="modprobe aufs failed: "ip: can't find device 'aufs'\nmodprobe: can't change directory to '/lib/modules': No such file or directory\n": exit status 1" 
2020-07-20T08:21:20.021487917Z time="2020-07-20T08:21:20.021435946Z" level=warning msg="could not use snapshotter zfs in metadata plugin" error="path /var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.zfs must be a zfs filesystem to be used with the zfs snapshotter: skip plugin" 
2020-07-20T08:21:20.021581245Z time="2020-07-20T08:21:20.021533539Z" level=warning msg="could not use snapshotter btrfs in metadata plugin" error="path /var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.btrfs must be a btrfs filesystem to be used with the btrfs snapshotter" 
2020-07-20T08:21:20.030531741Z time="2020-07-20T08:21:20.030427430Z" level=info msg="loading plugin "io.containerd.differ.v1.walking"..." type=io.containerd.differ.v1 
2020-07-20T08:21:20.030639854Z time="2020-07-20T08:21:20.030604536Z" level=info msg="loading plugin "io.containerd.gc.v1.scheduler"..." type=io.containerd.gc.v1 
2020-07-20T08:21:20.030779501Z time="2020-07-20T08:21:20.030736875Z" level=info msg="loading plugin "io.containerd.service.v1.containers-service"..." type=io.containerd.service.v1 
2020-07-20T08:21:20.030865060Z time="2020-07-20T08:21:20.030833703Z" level=info msg="loading plugin "io.containerd.service.v1.content-service"..." type=io.containerd.service.v1 
2020-07-20T08:21:20.030955439Z time="2020-07-20T08:21:20.030912981Z" level=info msg="loading plugin "io.containerd.service.v1.diff-service"..." type=io.containerd.service.v1 
2020-07-20T08:21:20.031027842Z time="2020-07-20T08:21:20.030998003Z" level=info msg="loading plugin "io.containerd.service.v1.images-service"..." type=io.containerd.service.v1 
2020-07-20T08:21:20.031132325Z time="2020-07-20T08:21:20.031083782Z" level=info msg="loading plugin "io.containerd.service.v1.leases-service"..." type=io.containerd.service.v1 
2020-07-20T08:21:20.031202966Z time="2020-07-20T08:21:20.031174445Z" level=info msg="loading plugin "io.containerd.service.v1.namespaces-service"..." type=io.containerd.service.v1 
2020-07-20T08:21:20.031286993Z time="2020-07-20T08:21:20.031253528Z" level=info msg="loading plugin "io.containerd.service.v1.snapshots-service"..." type=io.containerd.service.v1 
2020-07-20T08:21:20.031370557Z time="2020-07-20T08:21:20.031312376Z" level=info msg="loading plugin "io.containerd.runtime.v1.linux"..." type=io.containerd.runtime.v1 
2020-07-20T08:21:20.031709756Z time="2020-07-20T08:21:20.031650044Z" level=info msg="loading plugin "io.containerd.runtime.v2.task"..." type=io.containerd.runtime.v2 
2020-07-20T08:21:20.031941868Z time="2020-07-20T08:21:20.031897088Z" level=info msg="loading plugin "io.containerd.monitor.v1.cgroups"..." type=io.containerd.monitor.v1 
2020-07-20T08:21:20.032929781Z time="2020-07-20T08:21:20.032846588Z" level=info msg="loading plugin "io.containerd.service.v1.tasks-service"..." type=io.containerd.service.v1 
2020-07-20T08:21:20.033064279Z time="2020-07-20T08:21:20.033014391Z" level=info msg="loading plugin "io.containerd.internal.v1.restart"..." type=io.containerd.internal.v1 
2020-07-20T08:21:20.034207198Z time="2020-07-20T08:21:20.034120505Z" level=info msg="loading plugin "io.containerd.grpc.v1.containers"..." type=io.containerd.grpc.v1 
2020-07-20T08:21:20.034316027Z time="2020-07-20T08:21:20.034279582Z" level=info msg="loading plugin "io.containerd.grpc.v1.content"..." type=io.containerd.grpc.v1 
2020-07-20T08:21:20.034402334Z time="2020-07-20T08:21:20.034369239Z" level=info msg="loading plugin "io.containerd.grpc.v1.diff"..." type=io.containerd.grpc.v1 
2020-07-20T08:21:20.034482782Z time="2020-07-20T08:21:20.034452282Z" level=info msg="loading plugin "io.containerd.grpc.v1.events"..." type=io.containerd.grpc.v1 
2020-07-20T08:21:20.034564724Z time="2020-07-20T08:21:20.034533365Z" level=info msg="loading plugin "io.containerd.grpc.v1.healthcheck"..." type=io.containerd.grpc.v1 
2020-07-20T08:21:20.034645756Z time="2020-07-20T08:21:20.034617060Z" level=info msg="loading plugin "io.containerd.grpc.v1.images"..." type=io.containerd.grpc.v1 
2020-07-20T08:21:20.034722695Z time="2020-07-20T08:21:20.034689037Z" level=info msg="loading plugin "io.containerd.grpc.v1.leases"..." type=io.containerd.grpc.v1 
2020-07-20T08:21:20.034800005Z time="2020-07-20T08:21:20.034770572Z" level=info msg="loading plugin "io.containerd.grpc.v1.namespaces"..." type=io.containerd.grpc.v1 
2020-07-20T08:21:20.034873069Z time="2020-07-20T08:21:20.034837050Z" level=info msg="loading plugin "io.containerd.internal.v1.opt"..." type=io.containerd.internal.v1 
2020-07-20T08:21:20.036608424Z time="2020-07-20T08:21:20.036525701Z" level=info msg="loading plugin "io.containerd.grpc.v1.snapshots"..." type=io.containerd.grpc.v1 
2020-07-20T08:21:20.036722927Z time="2020-07-20T08:21:20.036684403Z" level=info msg="loading plugin "io.containerd.grpc.v1.tasks"..." type=io.containerd.grpc.v1 
2020-07-20T08:21:20.036799326Z time="2020-07-20T08:21:20.036769392Z" level=info msg="loading plugin "io.containerd.grpc.v1.version"..." type=io.containerd.grpc.v1 
2020-07-20T08:21:20.036876692Z time="2020-07-20T08:21:20.036844684Z" level=info msg="loading plugin "io.containerd.grpc.v1.introspection"..." type=io.containerd.grpc.v1 
2020-07-20T08:21:20.037291381Z time="2020-07-20T08:21:20.037244979Z" level=info msg=serving... address="/var/run/docker/containerd/containerd-debug.sock" 
2020-07-20T08:21:20.037493736Z time="2020-07-20T08:21:20.037445814Z" level=info msg=serving... address="/var/run/docker/containerd/containerd.sock" 
2020-07-20T08:21:20.037563487Z time="2020-07-20T08:21:20.037522305Z" level=info msg="containerd successfully booted in 0.069638s" 
2020-07-20T08:21:20.087933162Z time="2020-07-20T08:21:20.087804902Z" level=info msg="Setting the storage driver from the $DOCKER_DRIVER environment variable (overlay2)"
2020-07-20T08:21:20.088415387Z time="2020-07-20T08:21:20.088327506Z" level=info msg="parsed scheme: \"unix\"" module=grpc
2020-07-20T08:21:20.088533804Z time="2020-07-20T08:21:20.088465157Z" level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc
2020-07-20T08:21:20.088620947Z time="2020-07-20T08:21:20.088562235Z" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///var/run/docker/containerd/containerd.sock 0  }] }" module=grpc
2020-07-20T08:21:20.088709546Z time="2020-07-20T08:21:20.088654016Z" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
2020-07-20T08:21:20.092857445Z time="2020-07-20T08:21:20.092749940Z" level=info msg="parsed scheme: \"unix\"" module=grpc
2020-07-20T08:21:20.092962469Z time="2020-07-20T08:21:20.092914347Z" level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc
2020-07-20T08:21:20.093060327Z time="2020-07-20T08:21:20.093013905Z" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///var/run/docker/containerd/containerd.sock 0  }] }" module=grpc
2020-07-20T08:21:20.093142744Z time="2020-07-20T08:21:20.093102173Z" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
2020-07-20T08:21:20.149109416Z time="2020-07-20T08:21:20.148965236Z" level=info msg="Loading containers: start."
2020-07-20T08:21:20.159351905Z time="2020-07-20T08:21:20.159146135Z" level=warning msg="Running modprobe bridge br_netfilter failed with message: ip: can't find device 'bridge'\nbridge                167936  1 br_netfilter\nstp                    16384  1 bridge\nllc                    16384  2 bridge,stp\nip: can't find device 'br_netfilter'\nbr_netfilter           24576  0 \nbridge                167936  1 br_netfilter\nmodprobe: can't change directory to '/lib/modules': No such file or directory\n, error: exit status 1"
2020-07-20T08:21:20.280536391Z time="2020-07-20T08:21:20.280402152Z" level=info msg="Default bridge (docker0) is assigned with an IP address 172.18.0.0/16. Daemon option --bip can be used to set a preferred IP address"
2020-07-20T08:21:20.337028532Z time="2020-07-20T08:21:20.336889956Z" level=info msg="Loading containers: done."
2020-07-20T08:21:20.435200532Z time="2020-07-20T08:21:20.435033092Z" level=info msg="Docker daemon" commit=48a66213fe graphdriver(s)=overlay2 version=19.03.12
2020-07-20T08:21:20.436386855Z time="2020-07-20T08:21:20.436266338Z" level=info msg="Daemon has completed initialization"
2020-07-20T08:21:20.476621441Z time="2020-07-20T08:21:20.475137317Z" level=info msg="API listen on [::]:2375"
2020-07-20T08:21:20.477679219Z time="2020-07-20T08:21:20.477535808Z" level=info msg="API listen on /var/run/docker.sock"

[0;33m*********[0;m

[0KPulling docker image gitlab/dind:latest ...
[0;m[0KUsing docker image sha256:cc674e878f23bdc3c36cc37596d31adaa23bca0fc3ed18bea9b59abc638602e1 for gitlab/dind:latest ...
[0;msection_end:1595233326:prepare_executor
[0Ksection_start:1595233326:prepare_script
[0K[0K[36;1mPreparing environment[0;m
[0;mRunning on runner-fa6cab46-project-18378289-concurrent-0 via runner-fa6cab46-srm-1595233216-1bd30100...
section_end:1595233330:prepare_script
[0Ksection_start:1595233330:get_sources
[0K[0K[36;1mGetting source from Git repository[0;m
[0;m[32;1m$ eval "$CI_PRE_CLONE_SCRIPT"[0;m
[32;1mFetching changes with git depth set to 50...[0;m
Initialized empty Git repository in /builds/xxx.us/backend/.git/
[32;1mCreated fresh repository.[0;m
[32;1mChecking out 257ffdf2 as stage...[0;m

[32;1mSkipping Git submodules setup[0;m
section_end:1595233333:get_sources
[0Ksection_start:1595233333:restore_cache
[0K[0K[36;1mRestoring cache[0;m
[0;m[32;1mChecking cache for stage node:14.5.0-alpine-2...[0;m
Downloading cache.zip from https://storage.googleapis.com/gitlab-com-runners-cache/project/18378289/stage%20node:14.5.0-alpine-2[0;m 
[32;1mSuccessfully extracted cache[0;m
section_end:1595233334:restore_cache
[0Ksection_start:1595233334:step_script
[0K[0K[36;1mExecuting "step_script" stage of the job script[0;m
[0;mln: failed to create symbolic link '/sys/fs/cgroup/systemd/name=systemd': Operation not permitted
time="2020-07-20T08:22:14.844844859Z" level=warning msg="[!] DON'T BIND ON ANY IP ADDRESS WITHOUT setting -tlsverify IF YOU DON'T KNOW WHAT YOU'RE DOING [!]" 
time="2020-07-20T08:22:14.846663310Z" level=info msg="libcontainerd: new containerd process, pid: 57" 
time="2020-07-20T08:22:14.906788853Z" level=info msg="Graph migration to content-addressability took 0.00 seconds" 
time="2020-07-20T08:22:14.907996055Z" level=info msg="Loading containers: start." 
time="2020-07-20T08:22:14.910877638Z" level=warning msg="Running modprobe bridge br_netfilter failed with message: modprobe: ERROR: ../libkmod/libkmod.c:556 kmod_search_moddep() could not open moddep file '/lib/modules/4.19.78-coreos/modules.dep.bin'\nmodprobe: ERROR: ../libkmod/libkmod.c:556 kmod_search_moddep() could not open moddep file '/lib/modules/4.19.78-coreos/modules.dep.bin'\n, error: exit status 1" 
time="2020-07-20T08:22:14.912665866Z" level=warning msg="Running modprobe nf_nat failed with message: `modprobe: ERROR: ../libkmod/libkmod.c:556 kmod_search_moddep() could not open moddep file '/lib/modules/4.19.78-coreos/modules.dep.bin'`, error: exit status 1" 
time="2020-07-20T08:22:14.914201302Z" level=warning msg="Running modprobe xt_conntrack failed with message: `modprobe: ERROR: ../libkmod/libkmod.c:556 kmod_search_moddep() could not open moddep file '/lib/modules/4.19.78-coreos/modules.dep.bin'`, error: exit status 1" 
time="2020-07-20T08:22:14.989456423Z" level=warning msg="Could not load necessary modules for IPSEC rules: Running modprobe xfrm_user failed with message: `modprobe: ERROR: ../libkmod/libkmod.c:556 kmod_search_moddep() could not open moddep file '/lib/modules/4.19.78-coreos/modules.dep.bin'`, error: exit status 1" 
time="2020-07-20T08:22:14.990108153Z" level=info msg="Default bridge (docker0) is assigned with an IP address 172.18.0.0/16. Daemon option --bip can be used to set a preferred IP address" 

time="2020-07-20T08:22:15.029286773Z" level=info msg="Loading containers: done." 
time="2020-07-20T08:22:15.029664106Z" level=info msg="Daemon has completed initialization" 
time="2020-07-20T08:22:15.029823541Z" level=info msg="Docker daemon" commit=23cf638 graphdriver=overlay2 version=1.12.1 
time="2020-07-20T08:22:15.048665494Z" level=info msg="API listen on /var/run/docker.sock" 
time="2020-07-20T08:22:15.049046558Z" level=info msg="API listen on [::]:7070" 

# Keeps loading and finally fails after a couple of seconds

gitlab-ci.yml
cache:
  key: '$CI_COMMIT_REF_NAME node:14.5.0-alpine'
  paths:
    - node_modules/

stages:
  - release
  - deploy

variables:
  TAGGED_IMAGE: '$CI_REGISTRY_IMAGE:latest'

.release:
  stage: release
  image: docker:19.03.12
  services:
    - docker:dind
  variables:
    DOCKER_DRIVER: overlay2
    DOCKER_BUILDKIT: 1
  before_script:
    - docker version
    - docker info
    - echo "$CI_JOB_TOKEN" | docker login --username $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
  script:
    - docker build --pull --tag $TAGGED_IMAGE --cache-from $TAGGED_IMAGE --build-arg NODE_ENV=$CI_ENVIRONMENT_NAME .
    - docker push $TAGGED_IMAGE
  after_script:
    - docker logout $CI_REGISTRY

.deploy:
  stage: deploy
  image: gitlab/dind:latest
  services:
    - docker:dind
  variables:
    DOCKER_COMPOSE_PATH: '~/docker-composes/$CI_PROJECT_PATH/docker-compose.yml'
  before_script:
    - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
    - eval $(ssh-agent -s)
    - echo "$DEPLOY_SERVER_PRIVATE_KEY" | tr -d '\r' | ssh-add -
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - ssh-keyscan $DEPLOYMENT_SERVER_IP >> ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
  script:
    - rsync -avR --rsync-path="mkdir -p ~/docker-composes/$CI_PROJECT_PATH/; rsync" ./docker-compose.yml root@$DEPLOYMENT_SERVER_IP:~/docker-composes/$CI_PROJECT_PATH/
    - ssh root@$DEPLOYMENT_SERVER_IP "echo "$CI_REGISTRY_PASSWORD" | docker login --username $CI_REGISTRY_USER --password-stdin $CI_REGISTRY; docker-compose -f $DOCKER_COMPOSE_PATH rm -f -s -v $CI_COMMIT_REF_NAME; docker pull $TAGGED_IMAGE; docker-compose -f $DOCKER_COMPOSE_PATH up -d $CI_COMMIT_REF_NAME;"

release_stage:
  extends: .release
  only:
    - stage
  environment:
    name: staging

deploy_stage:
  extends: .deploy
  only:
    - stage
  environment:
    name: staging

Dockerfile
ARG NODE_ENV

FROM node:14.5.0-alpine

ARG NODE_ENV

ENV NODE_ENV ${NODE_ENV}

# Set working directory
WORKDIR /var/www/

# Install app dependencies
COPY package.json package-lock.json ./
RUN npm ci --silent --only=production

COPY . ./

# Start the application
CMD [ "npm", "run", "start" ]

docker-compose.yml
version: '3.8'

services:
  redis-stage:
    container_name: redis-stage
    image: redis:6.0.5-alpine
    ports:
      - '7075:6379'
    restart: always
    networks:
      - my-proxy-net

  stage:
    container_name: xxx-backend-stage
    image: registry.gitlab.com/xxx.us/backend:latest
    build: .
    expose:
      - '7070'
    restart: always
    networks:
      - my-proxy-net
    depends_on:
      - redis-stage
    environment:
      VIRTUAL_HOST: backend.xxx.us
      VIRTUAL_PROTO: https
      LETSENCRYPT_HOST: backend.xxx.us

networks:
  my-proxy-net:
    external:
      name: mynetwork

Update 1
I got a warning on the page claims I have used over 30% of my shared runner minutes. Maybe it is about not having enough minutes.
Update 2
The release stage gets completed successfully.
Update 3
Before I get into this problem, I deployed once successfully. I decided to test that commit once again and see if it succeeds, but it fails!

**Tags:** docker, docker-compose, gitlab, cicd, node.js


---

## 1 answers

### Answer by username_0 on 2020-07-20. Score: 1

I fixed the issue. In my case, it was `PORT` (absolutely) and `HOST` (maybe) environment variables I defined manually in the GitLab CI/CD Variables section. It seems `PORT` and maybe `HOST` are two reserved environment variables for GitLab and/or Docker.

By the way, I couldn't find anything in docs state not using those variables names.


---

