How to restart a single container with docker-compose

后端 未结 9 1853
失恋的感觉
失恋的感觉 2020-12-02 03:27

I have a docker-compose.yml file that contains 4 containers: redis, postgres, api, worker

During the development of worker, I often need to restart it i

9条回答
  •  暖寄归人
    2020-12-02 03:57

    It is very simple: Use the command:

    docker-compose restart worker
    

    You can set the time to wait for stop before killing the container (in seconds)

    docker-compose restart -t 30 worker
    

    Note that this will restart the container but without rebuilding it. If you want to apply your changes and then restart, take a look at the other answers.

提交回复
热议问题