Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker compose build single container

People also ask

Does Docker compose create a single container?

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 ).

Does Docker compose run multiple containers?

With Docker compose, you can configure and start multiple containers with a single yaml file.

Does Docker compose up recreate container?

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.