Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: swarm doesn’t kill off old containers #2053

Open
hkd987 opened this issue Apr 23, 2024 · 6 comments
Open

[Bug]: swarm doesn’t kill off old containers #2053

hkd987 opened this issue Apr 23, 2024 · 6 comments
Labels
🐛 Bug Reported issues that need to be reproduced by the team.

Comments

@hkd987
Copy link

hkd987 commented Apr 23, 2024

Description

Using docker swarm old containers are still active and running after a deploy.

Minimal Reproduction (if possible, example repository)

Deploy a nodejs app using docker swarm

Exception or Error

Old containers still running after a deploy & logs not being output.

Version

Lastest, however this has been going on for some time.

@hkd987
Copy link
Author

hkd987 commented Apr 23, 2024

Currently I’m testing a less than ideal workaround where I stop the containers and then deploy again.

@hkd987
Copy link
Author

hkd987 commented Apr 23, 2024

Stopping all services before deploy resolves this issue although this isn't ideal and prevents rolling updates.

@hkd987 hkd987 changed the title [Bug]: swarm doesn’t kill off old containers & logs are broken [Bug]: swarm doesn’t kill off old containers May 3, 2024
@andrasbacsai andrasbacsai self-assigned this May 4, 2024
@peaklabs-dev peaklabs-dev added the 🐛 Bug Reported issues that need to be reproduced by the team. label Oct 22, 2024
@peaklabs-dev peaklabs-dev added this to the v4.0.0 Stable Release milestone Oct 22, 2024
@garyhtou
Copy link
Contributor

This is a shot in the dark, but maybe the solution is to add the --prune flag when calling docker stack deploy.

executeInDocker($this->deployment_uuid, "docker stack deploy --detach=true --with-registry-auth -c {$this->workdir}{$this->docker_compose_location} {$this->application->uuid}"),

From what I'm observing, Coolify generates a new service name per deployment. Without the --prune flag, Docker will keep the old services running even if they are no longer referenced in the new stack/docker-compose file.

I've thrown together PR #5141 in case it is the solution. However, I haven't gotten around to testing it yet.

@djsisson
Copy link
Contributor

Out of interest is this seperate from dockers rollback feature for swarm, as it will keep your old containers incase you need to rollback

@garyhtou
Copy link
Contributor

I believe this is separate. From my understanding, the rollback feature keeps old images. When you decide to rollback, it creates a new deployment using the old image. It doesn't keep old containers running.

@djsisson
Copy link
Contributor

djsisson commented Feb 20, 2025

If this is generating a diff uuid everytime then it will still create a new stack and leave old one running

Maybe switch to name?

Oh its the id of the service inside the app that changes, OK yeah this should be fine then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Reported issues that need to be reproduced by the team.
Projects
None yet
Development

No branches or pull requests

5 participants