Container name pattern ignored when stopping
See original GitHub issueDescription
I want to run concurrent builds on a single docker host (for CI).
I started two builds with -Ddocker.containerNamePattern="$BUILD_TAG-%n-%i"
(e.g. -Ddocker.containerNamePattern=build-1-%n-%i
and -Ddocker.containerNamePattern=build-2-%n-%i
).
I expected the builds to ignore each other’s containers, only stopping the ones that match their respective build pattern, but instead they stop each other’s containers.
This results in errors because containers being stopped mid-use.
12:59:54 [ERROR] DOCKER> [acme-all:latest] "acme-all": Container stopped with exit code 137 unexpectedly after 35529 ms while waiting on healthcheck '"CMD-SHELL", "wget --server-response -q -O /dev/null http://localhost:8080/acme/status || exit 1"'
12:59:54 [ERROR] DOCKER> Error occurred during container startup, shutting down...
12:59:54 [ERROR] DOCKER> Unable to remove container [b097fd97dc80] : removal of container b097fd97dc80 is already in progress (Conflict: 409) [removal of container b097fd97dc80 is already in progress (Conflict: 409)]
While in the other build log there is
12:59:54 [INFO] DOCKER> [acme-all:latest]: Stop and removed container b097fd97dc80 after 0 ms
Info
- d-m-p version : 0.27.2
- Maven version (
mvn -v
) : 3.5 - Sample project: https://github.com/jakub-bochenski/demp-concurrent-stop
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Stopping Docker containers by image name - Ubuntu
Then in your command line, simply do dockstop myImageName and it will stop and remove all containers that were started from an image...
Read more >fabric8io/docker-maven-plugin
When containers associated with this image will be stopped by docker:stop, use this pattern list to find containers to remove rather than just ......
Read more >Troubleshooting the container runtime - Google Cloud
Find the latest cAdvisor release with the name pattern vX. ... For privileged Pods, the container runtime ignores any device mappings that volumeDevices....
Read more >Stop Docker Containers by Name Using Patterns
Docker makes it easy to stop containers by a specific container name, but here's how you can stop containers by a wild card...
Read more >Docker Anti Patterns - Codefresh
In this article, we'll present several bad practices with container usage and the solution to each one.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We have a similar issue but in our case the containerNamePattern is just %a. I can provide a fix for that and maybe I can also try to fix the original issue.
The current implementation treats index placeholders specially. All containers are stopped except the one with the highest index (see https://github.com/fabric8io/docker-maven-plugin/blob/master/src/main/java/io/fabric8/maven/docker/util/ContainerNamingUtil.java#L85). Why is this necessary? I don’t get it.
However, for me it’s not clear how we should handle the stopping process when the containerNamePattern contains %i or %t. Both parameters are automatically generated (see
io.fabric8.maven.docker.util.ContainerNamingUtil#formatContainerName
) and they are not available when the stop mojo is executed.Proposal: