we’re trying to move from a standalone runner over to the Docker-based runner. So the concepts are bit different and not that easy to understand at all.
I have a repo with some code inside and i want to use a runner to validate it. I set up a Dockerfile with all my necessary tools and pushed it to my registry. In the next stage and want this container to check the code inside my repository. But I’m struggeling to bind/mount my repo-folder into the container.
variables: DOCKER_DRIVER: overlay2 DOCKER_BUILDKIT: 1 CI_REGISTRY: ************* CI_REGISTRY_IMAGE: ************/test CI_REGISTRY_USER: ****** CI_REGISTRY_PASSWORD: *********** stages: - build - test before_script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY build_container: stage: build only: changes: - Dockerfile tags: - docker before_script: - docker pull $CI_REGISTRY_IMAGE:latest script: - docker build --cache-from $CI_REGISTRY_IMAGE:latest -t $CI_REGISTRY_IMAGE . after_script: - docker push $CI_REGISTRY_IMAGE:latest validate: stage: test script: - docker run $CI_REGISTRY_IMAGE /bin/ash -c "uname -a && java -version && ls -la && ls -la /mnt"
I already tried to extend the docker run with -v $CI_PROJECT_DIR:/mnt but I got an error that “-v” is not an executable.
So, there are two things I would like to know:
- Is my idea by building a container and re-use it for every validation run right?
- How can I mount a volume inside my container or is there another / better solution?