Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to quickly update a running docker-compose container

How do you quickly update one running service using docker-compose.

I find myself often running docker-compose stop SERVICE, docker-compose build SERVICE and docker-compose up -d SERVICE.

Is there an easier way, preferably with little down time.

like image 975
Stephen Avatar asked Feb 01 '16 08:02

Stephen


People also ask

Does Docker compose auto update?

In this tutorial, you will use Watchtower with both Docker's run command and Docker Compose to automatically update a Docker image. Both methods are functionally the same in creating a container running Watchtower, then pointing it towards a container you wish to keep automatically updated.


2 Answers

In dev environment I would suggest you to create a volume mapped to your source code tree and setup hot reload.

For production there is an article suggesting the next command:

docker-compose -f docker-compose.prod.yml up --build --no-deps -d SERVICE
like image 95
Sergei Lubianov Avatar answered Oct 18 '22 14:10

Sergei Lubianov


If you're having to restart it to pickup code changes you could try using a volume.

Otherwise the commands you are running are the fastest option. If stop is taking 10 seconds see https://docs.docker.com/compose/faq/#why-do-my-services-take-10-seconds-to-stop, or consider using docker-compose kill SERVICE to force shutdown.

like image 45
dnephin Avatar answered Oct 18 '22 16:10

dnephin