How to save the Docker container that was used to build in Gitlab CI?

I am using Gitlab CI in conjunction with a runner using Docker. In the git repository of the project in Gitlab, I posted the .gitlab-ci.yml file. Clicking this file forces the runner to create a Docker container based on the Docker image that I provided. Then it starts the assembly steps installed in the yml file. This works very well when the build completes successfully.

However, if the assembly failed, I would like to find the reason in the Docker container that was used to run this assembly. Is it possible?

The output of "docker ps" indicates that the container is running during build, but then the output of "docker ps -a" indicates that the container is completely removed. Is there any way to prevent this?

+4
source share
1 answer

At this time, it is not intended for the developer. Perhaps this is possible, but if there is a way to do this, it will be more complex than useful if you want the container after it starts. I would say no. Its against the basic idea of ​​testing with a docker, in my opinion.

But I have an idea of ​​a workaround:

Suppose you have a project with a file .gitlab-ci.yml. You can run the docker container yourself, where the docker is installed:

docker run -it debian:latest

and do your tests yourself. I think this is not practical, but it is a possible way. Perhaps this helps.

0
source

Source: https://habr.com/ru/post/1624933/


All Articles