question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Container name pattern ignored when stopping

See original GitHub issue

Description

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
j3tcommented, Jan 14, 2021

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.

0reactions
j3tcommented, Jan 16, 2021

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:

  • all containers where the name matches the containerNamePattern are stopped
  • %a is replaced with the alias of the image configuration (equivalent to the start mojo)
  • %n is replaced with the name of the image configuration (equivalent to the start mojo)
  • %i is replaced with any number (\d+)
  • %t is replaced with any date (\d{10,})
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found