9

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

3 Answers 3

8

Just remove the target :)

docker-compose -f .docker/docker-compose.yml build www
Sign up to request clarification or add additional context in comments.

Comments

1
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)**

Comments

1

Just apply this command: docker-compose up -d --no-deps --build <service_name>

In your case: docker-compose up -d --no-deps --build www

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.