9

I am using Gitlab CI in combination with a runner that uses Docker. In the git repo of a project in Gitlab, I have placed a .gitlab-ci.yml file. Pushing this file causes the runner to create a Docker container based on the Docker image I have provided. It then runs the build steps laid down in the yml file. This works very well when the build succeeds.

However, when the build fails, I would like to be able to find the cause in the Docker container that was used to run this build. Is this possible?

The output of 'docker ps' shows that the container is running during the build, but afterwards the output of 'docker ps -a' shows that the container was removed completely. Is there any way to prevent this?

2 Answers2

0

At this time, its not intended from the developer. Maybe its possible, but if there is a way to do so, its more complicated than useful if you want the container after running it. I would say no. Its against the basic idea of testing with docker in my opinion.

But I have an idea for a workaround:

Assume you have a project with a .gitlab-ci.yml file in it. You could run a docker container by yourself wherever docker is installed:

docker run -it debian:latest

and run your tests by yourself. I think this way is not practical, but its a possible way. Maybe it helps.

Rubinum
  • 547
  • 3
  • 18
  • 2
    I think his reason for wanting to save the container is for easier debugging, if there's something wrong with the build process it would be really simple to do fix it if we could somehow keep the container – Clive Makamara Sep 24 '17 at 17:41
0

Soon this will be possible with a web terminal (11.3), which will keep the container alive while the the terminal is connected. webterminal

Danny
  • 1,603
  • 1
  • 15
  • 25
  • 1
    This sounds promising, however this does not work at the moment, from the link you posted: " The docker executor does not keep running after the build script is finished. At that point, the terminal will automatically disconnect and will not wait for the user to finish. Please follow this issue for updates on improving this behavior" – Étienne Sep 11 '19 at 14:04