Wowu / docker-rollout

🚀 Zero Downtime Deployment for Docker Compose
https://github.com/Wowu/docker-rollout
MIT License
2.18k stars 59 forks source link

Uses the older image for the new container #31

Open dcodesdev opened 1 month ago

dcodesdev commented 1 month ago

When I'm updating my container with docker rollout it creates two images, <dirname>_<service-name> and <dirname>-<service-name> (one of them separated by _ and the other by -)

These are two different images, one of them doesn't get updated (from days ago) and the other is the new one built by docker-compose -f <file>.yaml build backend just before running docker rollout

The problem is that when running docker rollout -f <filename> it creates a new container but uses the older image therefore it doesn't update anything.

I don't know what is happening behind the scenes but took me hours of debugging until I found out the issue was docker rollout.

dcodesdev commented 1 month ago

I added the image field for the docker-compose.yaml file, now it works.

But the bug still exists if you don't specify an image field for your service.

Wowu commented 1 month ago

The difference comes from using different tools. docker rollout uses docker compose(v2) over docker-compose (v1) if it's available. The naming convention must have changed and now hyphens are used instead of underscores.

I suggest using Docker Compose now, as docker-compose is deprected. It probably means replacing docker-compose with docker compose in your scripts 😃

If you want to keep using docker-compose instead, you can patch lines 34-42 (linked below) in the script to set COMPOSE_COMMAND=docker-compose.

https://github.com/Wowu/docker-rollout/blob/93a733199a4a02d183ef84d494611ac12ac99024/docker-rollout#L34-L42

dcodesdev commented 1 month ago

Makes sense!

Maybe add it to the caveats list in the readme file so that others don't make the same mistake as I did.

Thank you for your help!