Get a file out of a docker container running using Kubernetes in Gitlab

8/12/2021

Gitlab is configured to execute multiple tasks and each task is running in a separate docker container. There are multiple tasks setup as:

stages:
  - setup
  - package
  - cleanup
  - test 

All the containers are created using the command:

  script:
    - docker build -t $REGISTRY_URL/$COMPONENT:$CI_COMMIT_REF_SLUG --file $CI_PROJECT_DIR/resources/docker/$COMPONENT/Dockerfile $CI_PROJECT_DIR
    - docker push $CI_REGISTRY/$COMPONENT:$CI_COMMIT_REF_SLUG

After the final stage some of the $COMPONENT creates reports which need to obtained as artifacts. But since they are getting executed in separate docker containers I am not aware how they can be fetched from the container. I could try the below lines only if the path of artifact is with reference to $CI_PROJECT_DIR.

artifacts:
    paths:
      - output/
    expire_in: 1 week

But in My case all the containers are running using Kubernetes in Gitlab and hence final test reports of my application are residing inside each containers. What will be best way to get the documents out of the docker containers?

-- Jis
containers
docker
gitlab
gitlab-ci
kubernetes

0 Answers