docker compose build single container
docker-compose up -d --no-deps --build <service_name>
Source
Yes, use the name of the service:
docker-compose build elasticsearch
You could added --no-start
flag to docker-compose, and start later since you will only build one service.
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:
.....