Docker containers are not removed after a build completes
症状
When running a non-detached container in Bamboo using the Docker task, and the container fails to start, the Bamboo build will fail but the Docker container is not removed on completion of the task.
There may be an error in the logs related to the command being executed inside the container but it will not hint that the container is not removed.
Possible excessive disk usage may hint at the problem.
原因
Non-detached containers are run with the --rm
argument meaning that Docker should remove them when the process exits. However, if the container is unable to start due to misconfiguration of the command to be executed in the container, Docker will not remove it. This is presumably so that the cause of the error can be diagnosed.
ソリューション
The leftover containers will not influence subsequent builds so may go unnoticed for some time. If the Docker service on the agent hasn't been restarted in a while this may lead to excessive disk usage. You can reclaim the disk space by manually removing the container using the docker rm
command, for example:
docker rm my-failed-container
Of course, you should also correct any misconfigured container in a failing build.
Note: Feature request opened for the above scenarios - BAM-21766Getting issue details... STATUS