How can I get "docker-compose scale" to use the latest image for any additional instances created? -


in project, have number of micro-services rely upon each other. using docker compose bring in right order.

during development, when write new code container, container need restarted, new code can tried. far i've been using restart of whole thing, thus:

docker-compose down && docker-compose -d 

that works fine, bringing down , again takes ~20 seconds, long live environment. therefore looking various strategies ensure micro-services may rebooted individually no interruption @ all.

my first approach, works, scale service reboot, 1 instance two. programmatically reset reverse proxy (traefik) point new instance, , when happy, docker stop on old one.

my scale command old variety, since using compose 1.8.0. looks this:

docker-compose scale missive-storage-backend=2 

the problem if there new image, docker compose not use - stubbornly uses hash identical running instance. i've checked docker-compose scale --help , there nothing in there relating forcing use of new image.

now could use ordinary docker run, i'd have replicate options i've set service in docker-compose.yml, , don't know if run outside of compose file understood being part of compose application (e.g. stopped docker-compose down despite having been started manually?).

it's possible later versions of docker compose may have more options in scale function (it has been merged up anyway).

what simplest way feature?

(aside: appreciate there myriad of orchestration tools gentle reboots , other wizardry, , surely explore bottomless pit when have time available. now, feel writing few scripts deployment tasks quicker win.)

i've fixed this. firstly tried upgrading compose 1.9, didn't seem offer changes need. bumped 1.13, when scale becomes deprecated separate command, , appears switch up command.

as test, have image called missive-storage, , add dummy change dockerfile, docker ps reports name of image in running container d4ebdee0f3e2 instead (since missive-storage:latest has changed).

the ps line looks this:

container id        image                  command                  created             status              ports                                                      names 45b8023f6ef1        d4ebdee0f3e2           "/usr/local/bin/du..."   4 minutes ago       4 minutes                                                                   app_missive-storage-backend_1 

i issue command (missive-storage-backend dc service name image missive-storage):

docker-compose -d --no-recreate --scale missive-storage-backend=2 

which results in these containers:

container id        image                  command                  created             status              ports                                                      names 0bd6577f281a        missive-storage        "/usr/local/bin/du..."   2 seconds ago       2 seconds                                                                   app_missive-storage-backend_2 45b8023f6ef1        d4ebdee0f3e2           "/usr/local/bin/du..."   4 minutes ago       4 minutes                                                                   app_missive-storage-backend_1 

as can see, gives me 2 running containers, 1 based on old image, , 1 based on new image. here can redirect traffic sending configuration change front-end proxy, stop old container.

note --no-recreate important - without it, docker compose seems liable reboot everything, defeating object of exercise.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -