Hi,
I’m having some difficulty using docker-compose to build containers on shared runners and hope that someone may have seen a similar issue previously or can help me debug it.
My goal is to have GitLab CI automatically build, test and publish containers from my docker-compose.yml
, with a manual step to deploy the published containers onto a server. In order to make docker-compose available from the test runner, I use an extension of the official Docker image, which has Docker Compose installed.
My .gitlab-ci.yml
is as follows (only one job included, for brevity):
image: djbingham/docker-compose
services:
- docker:dind
before_script:
- apk update
- apk add bash
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
stages:
- build
- test
- publish
- deploy
...
build:data_api:
stage: build
script:
- services/data/script/prepare # runs composer install using official Docker image
- docker-compose build data_api
- docker-compose push data_api
...
When this is run through the GitLab CI pipeline, the build:data_api
step produces the expected output for composer install, followed by:
$ docker-compose build data_api
Building data_api
ERROR: Job failed: exit code 141
I’ve been searching for a while and found only two suggestions:
- the presence of a ‘.swp’ file can cause this error.
- Perhaps docker-compose ran out of memory.
I tried adding ls -la
just before the docker-compose build
command and saw that no .swp
file (or similar) exists on the runner at that point.
With regard to memory, I don’t know how much is typically available on a shared runner. It appears to have failed at the first step of building the container image, which copies in the vendor folder generated by the preceding composer install
. Running docker-compose build
on my development machine works fine and yields a final image size of 381 MB.