Skip to content

fix: make dockertest able to run inside a container

Jon Foss Mikalsen requested to merge run-inside-container into master

Adds the possibility to run dockertest inside a container, this could typically be used in CI/CD contexts.

Introduces two new env variables to make this work:

  • DOCKERTEST_RUN_IN_CONTAINER Has to be set to 1 to signal to dockertest that its running inside a container
  • DOCKERTEST_CONTAINER_ID Has to be set to the container ID or name of the container dockertest is running inside of.

I found no reliable way of detecting that we're inside a container or get our container ID/name that I'm confident will work in all environments.

Tested this in our local CI/CD environment with gitlab runners. Retrieved the container ID with the following command.

  • docker ps -q -f "label=com.gitlab.gitlab-runner.job.id=$CI_JOB_ID" -f "label=com.gitlab.gitlab-runner.type=build"

Merge request reports