Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build specific service using docker-compose?

How do I target my build using docker-compose to one of the services I have in docker-compose.yml?

My docker-compose.yml for example:

version: '3'

services:
  admin:
    image: 8205037.dkr.ecr.us-east-2.amazonaws.com/admin:latest
    build:
      context: ../
      dockerfile: ./.docker/Dockerfile-admin

  www:
    image: 233232037.dkr.ecr.us-east-2.amazonaws.com/www:latest
    build:
      context: ../
      dockerfile: ./Dockerfile-www

And how to build only the www without change the file? I want to run something like this:

docker-compose -f .docker/docker-compose.yml build --target www

like image 601
Jon Sud Avatar asked May 21 '26 06:05

Jon Sud


2 Answers

Just remove the target :)

docker-compose -f .docker/docker-compose.yml build www
like image 80
Shlomi Levi Avatar answered May 24 '26 04:05

Shlomi Levi


docker-compose -f **(path docker-compose file)** build **(container name)**

If it's the first time.

docker-compose -f **(path docker-compose file)** up -d **(container name)**
like image 44
Hiro Dev Avatar answered May 24 '26 03:05

Hiro Dev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!