You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
docker compose up recreates running container that does not have their configs changed in docker-compose.yml #9600
docker compose up stops and recreates running containers that do not have their config changed.
Steps to reproduce the issue:
Run docker compose up
Change config for one service in docker-compose.yml
Run docker compose up again
Describe the results you received:
A lot of containers that are not related to the service that has its config changed are recreated and restarted.
Describe the results you expected:
Only the container of the service that has new config should be recreated and those that depend on it should be restarted.
Additional information you deem important (e.g. issue happens only occasionally):
After switching to v2 it happens almost all of the time. Previously on v1 there was no such problem.
I think the mechanism for determining config changes is by hashing the config and storing that hash in the label com.docker.compose.config-hash.
You can check if the label changes between invocations to further verify what's going on.
Different compose executable versions will sometimes produce different hash outputs on the same config file, so make sure tests are done with a consistent binary version.
I'm getting the same issue and all images are available locally.
In my case, it's triggered by a docker-compose run, and a linked running container gets recreated even though nothing has changed.
I checked the hash, it does not change across the unexpected recreates.
EDIT: as pointed out in #10068, in my case the result of docker-compose config --hash <service> does not change, but the result of docker inspect <container> -f '{{json .Config.Labels}}' | jq -r '."com.docker.compose.config-hash"' does change
Seeing this issue on v2.14.0 too - any word on a fix? We have a use cae where we need to gradually add some services to the compose file and start them only after confirming the previous service is happy and healthy.
After I commented on this, I discovered the flag “-- no-recreate” which seems to solve the problem for me. But I don’t understand why this behaviour isn’t the default. Note we just moved from compose 1.x to latest 2.x so still figuring out a few changes.
After I commented on this, I discovered the flag “-- no-recreate” which seems to solve the problem for me. But I don’t understand why this behaviour isn’t the default. Note we just moved from compose 1.x to latest 2.x so still figuring out a few changes.
That flag shouldn't be the default, you're just working around the bug.
Hi guys, this is a pretty bad regression on well established behaviour of docker compose. We will likey need to return to version 1.x until this is addressed - what needs to happen to have the core developers take a serious look at this?
images in composer file is not available locally (alpine:latest, httpd:2.4, centos/postgresql-12-centos7). If they already exist, remove them.
Step:
docker-compose up -d.
sleep 90 (optional and doesn't affect the result)
docker-compose run --rm two echo 123. All running containers will be recreated at this step
Note
It occurs if the images are not available locally
it doesn't occur if the service is started with --no-deps or service has no linked services
@sillidev does it not make sense to recreate those containers if the one you're running (run means a new container than what up -d created) depends on those directly or indirectly? You lost me there. This doesn't seem like a regression.
rethinking - if run creates a new container to "run" a command, maybe it should run the dependencies individually as well?
So after the test above, I changed the binary back from v2.6.0 to v2.17.0-rc.1, and ran docker compose up -d again, and both container got recreated, although the images did not change, nor did the compose file content. So the trigger is possibly how the problematic compose binary created the containers?
@imjuzcy please check the com.docker.compose.config-hash label set on containers, and compare with docker config --hash "*". If compose file has no change, those should match (and container won't be recreated)
Please notice hash computation had some bugs in the past, so switching between compose releases might trigger containers to be recreated, but this is expected then.
thankfully just came across this issue and I managed to use apt (on Ubuntu 22.10) to update from v2.16 to v2.17.2 and this solved my problem.
Thank you!
Upgrading the package on my Debian 11 server also fixed this issue. Unpacking docker-compose-plugin (2.17.2-1~debian.11~bullseye) over (2.16.0-1~debian.11~bullseye)
Not sure if it is a similar issue, but today I face the problem running docker-compose up recreates containers from another project . Two different project in different folders if I call up in project A it recreates project B and viceversa. First I try rename container_name (which was obviously different) but no success. I add COMPOSE_PROJECT_NAME to .env file to project A and now it works fine. https://docs.docker.com/compose/environment-variables/envvars/#compose_project_name
Activity
debdutdeb commentedon Jun 30, 2022
I can't reproduce locally. Can you provide a sample compose file?
I tried with this,
Once without network then with for the
oneservice.imjuzcy commentedon Jun 30, 2022
@debdutdeb I tried with your compose file, and ran
docker compose up -dtwice (with around one minute in between) without modifying anything.The first run, both of the containers came up. This is expected. The second run, both of them are recreated, but I did not modify anything.
Afterwards, I tried it again, it does not happen. Even with modified compose file, it doesn't always occur.
debdutdeb commentedon Jun 30, 2022
Noticed i was using 2.0.something - old fork of mine. Checking again with 2.6.x.
debdutdeb commentedon Jun 30, 2022
Looks like you're right 👀
debdutdeb commentedon Jun 30, 2022
But can't reproduce reliably though.
imjuzcy commentedon Jun 30, 2022
Yea, it does not always occur, yet I don't see a pattern as to why it occurs when it occurs
RaphMad commentedon Jul 1, 2022
I think the mechanism for determining config changes is by hashing the config and storing that hash in the label
com.docker.compose.config-hash.You can check if the label changes between invocations to further verify what's going on.
Different compose executable versions will sometimes produce different hash outputs on the same config file, so make sure tests are done with a consistent binary version.
benlangfeld commentedon Sep 8, 2022
Is this a duplicate of #9357?
sillidev commentedon Oct 3, 2022
I'm facing this issue in docker-compose 2.11.2. To reliably reproduce :
Compose file
Pre-condition:
Step:
docker-compose up -d.sleep 90(optional and doesn't affect the result)docker-compose run --rm two echo 123. All running containers will be recreated at this stepNote
--no-depsor service has no linked servicesswingbit commentedon Dec 2, 2022
I'm getting the same issue and all images are available locally.
In my case, it's triggered by a
docker-compose run, and a linked running container gets recreated even though nothing has changed.I checked the hash, it does not change across the unexpected recreates.
EDIT: as pointed out in #10068, in my case the result of
docker-compose config --hash <service>does not change, but the result ofdocker inspect <container> -f '{{json .Config.Labels}}' | jq -r '."com.docker.compose.config-hash"'does changev2.12.0
captainfalcon23 commentedon Dec 20, 2022
Seeing this issue on v2.14.0 too - any word on a fix? We have a use cae where we need to gradually add some services to the compose file and start them only after confirming the previous service is happy and healthy.
captainfalcon23 commentedon Dec 20, 2022
After I commented on this, I discovered the flag “-- no-recreate” which seems to solve the problem for me. But I don’t understand why this behaviour isn’t the default. Note we just moved from compose 1.x to latest 2.x so still figuring out a few changes.
benlangfeld commentedon Dec 20, 2022
That flag shouldn't be the default, you're just working around the bug.
zephyia commentedon Jan 24, 2023
Hi guys, this is a pretty bad regression on well established behaviour of docker compose. We will likey need to return to version 1.x until this is addressed - what needs to happen to have the core developers take a serious look at this?
debdutdeb commentedon Jan 24, 2023
@sillidev does it not make sense to recreate those containers if the one you're running (
runmeans a new container than whatup -dcreated) depends on those directly or indirectly?You lost me there. This doesn't seem like a regression.rethinking - if run creates a new container to "run" a command, maybe it should run the dependencies individually as well?
37 remaining items
imjuzcy commentedon Mar 9, 2023
So after the test above, I changed the binary back from v2.6.0 to v2.17.0-rc.1, and ran
docker compose up -dagain, and both container got recreated, although the images did not change, nor did the compose file content. So the trigger is possibly how the problematic compose binary created the containers?ndeloof commentedon Mar 9, 2023
@imjuzcy please check the
com.docker.compose.config-hashlabel set on containers, and compare withdocker config --hash "*". If compose file has no change, those should match (and container won't be recreated)Please notice hash computation had some bugs in the past, so switching between compose releases might trigger containers to be recreated, but this is expected then.
imjuzcy commentedon Mar 9, 2023
Ah, got it.
But back to v2.17.0-rc.1, it's still solid for me, no unnecessary recreates so far.
itsthejb commentedon Mar 9, 2023
I also updated to the rc, and working very nicely with nicer coloured output 😆
I've got auto-updates for compose, so it seems this got broken in v2.16.0...
ndeloof commentedon Mar 10, 2023
Closing this issue then, feel free to comment / open a follow-up if this strikes back with 2.17+
leranp commentedon Mar 12, 2023
Sorry,but how can i install the v2.17.0 version in debian?
ndeloof commentedon Mar 12, 2023
@leranp download binary from https://github.com/docker/compose/releases and install under
~/.docker/cli-pluginsoleg-erom commentedon Mar 16, 2023
@ndeloof You missed the
sat the end~/.docker/cli-plugins(I wasted some time figuring out why it doesn't work)aehlke commentedon Mar 21, 2023
Any tip for installing on Ubuntu? Or even just how to downgrade on Ubuntu to avoid this regression
louis-lau commentedon Mar 21, 2023
@aehlke https://docs.docker.com/compose/install/linux/#install-the-plugin-manually
Basically the instructions provided just above your reply. Did you try them before asking? Personally I'll just wait for the next release.
aehlke commentedon Mar 22, 2023
Yes I had tried it without luck. Looks like my system has something wrong with it if those are also the ubuntu intructions. Thank you
theonlysinjin commentedon Mar 29, 2023
thankfully just came across this issue and I managed to use apt (on Ubuntu 22.10) to update from
v2.16tov2.17.2and this solved my problem.Thank you!
FingerlessGlov3s commentedon Mar 30, 2023
Upgrading the package on my Debian 11 server also fixed this issue.
Unpacking docker-compose-plugin (2.17.2-1~debian.11~bullseye) over (2.16.0-1~debian.11~bullseye)za-ek commentedon Mar 5, 2024
Not sure if it is a similar issue, but today I face the problem running
docker-compose uprecreates containers from another project . Two different project in different folders if I callupin project A it recreates project B and viceversa. First I try rename container_name (which was obviously different) but no success. I add COMPOSE_PROJECT_NAME to .env file to project A and now it works fine.https://docs.docker.com/compose/environment-variables/envvars/#compose_project_name