Using the Compose command line tool you can create and start one or more containers for each dependency with a single command ( docker-compose up ).
With Docker compose, you can configure and start multiple containers with a single yaml file.
If there are existing containers for a service, and the service's configuration or image was changed after the container's creation, docker compose up picks up the changes by stopping and recreating the containers (preserving mounted volumes).
Yes, use the name of the service:
docker-compose build elasticsearch
docker-compose up -d --no-deps --build <service_name>
Source
if you want to run and recreate a specific service inside your docker-compose file you can do it the same way as @dnephin proposed, like
$ docker-compose up -d --force-recreate --no-deps --build service_name
Suppose your docker-compose.yml file is like
version: '3'
services:
service_1:
.....
service_2:
.....
You could added --no-start
flag to docker-compose, and start later since you will only build one service.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With