Best way to start a docker container during a task

#1

In many of our projects that we continuously integrate with Concourse, we use TestContainers library to create various disposable containers in integration tests. Some examples include Postgres, Redis, Localstack. There containers are destroyed (by the library) once tests are finished.

Till now we’ve been really running “Docker in Docker”:

  • Alpine based on github concourse/docker-image-resource/blob/master/assets/common.sh
  • Ubuntu based on github jpetazzo/dind

After update to Concourse 5.0 / “overlay” worker baggage claim driver, Docker daemon is no longer able to start.
After I applied https://github.com/concourse/docker-image-resource/commit/fd492346246e9e9f61040bf31c740e80fccc9365 for our Alpine solution it worked, but for Ubuntu I still have to find a solution.

Next to it, running “Docker in Docker” is not recommended (e.g., here: https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/).

I am wondering what would be a recommended approach to spin up docker containers during builds on CI that would be forward compatible?

0 Likes

#2

A workaround is to still use btrfs on worker by add --baggageclaim-driver=btrfs. But with 5.0.0, concourse binary seems no longer embed btrfs and mkfs.btrfs binaries, if your worker doesn’t contain those two binary files, you may have to manually install them, then use --baggageclaim-btrfs-bin= and --baggageclaim-mkfs-bin= to specify paths of them.

0 Likes

#3

@evanchaoli, thanks for the workaround.
For now, I can probably follow commits on https://github.com/concourse/docker-image-resource to have a working solution for Alpine. However, I think the idea is to have it deprecated eventually and get/build images without Docker actually running.
For Ubuntu setup, I’ll probably still have to fix it myself.

But I was wondering more about the long term approach, so that I don’t need to apply fixes now and then when new version of Concourse comes out.
I think there should be quite some teams out there that use Docker for spinning up resources during (integration) tests as a part of build scripts (maven, Gradle, …) to ensure quicker feedback when running both on developers machines and in CI.
Ideally, I would like to have a task configuration similar to Travis CI:
- task: build image: jdk file: git/ci/tasks/build.yml timeout: 30m services: [docker] ...
(with DOCKER_HOST passed to the task, e.g.).

0 Likes

#4

this is an ongoing gap in concourse today: https://github.com/concourse/concourse/issues/324 for more info

0 Likes