How to restart a single container with docker-compose

后端 未结 9 1862
失恋的感觉
失恋的感觉 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 04:11

    Restart Service with docker-compose file

    docker-compose -f [COMPOSE_FILE_NAME].yml restart [SERVICE_NAME]
    

    Use Case #1: If the COMPOSE_FILE_NAME is docker-compose.yml and service is worker

    docker-compose restart worker
    

    Use Case #2: If the file name is sample.yml and service is worker

    docker-compose -f sample.yml restart worker
    

    By default docker-compose looks for the docker-compose.yml if we run the docker-compose command, else we have flag to give specific file name with -f [FILE_NAME].yml

提交回复
热议问题