Toshi
Toshi

Reputation: 6342

docker-compose up vs docker-compose up --build vs docker-compose build --no-cache

I couldn't figure out what the difference between those.

Is there any command for upwithout cache?

Upvotes: 286

Views: 140702

Answers (2)

Ayemun Hossain Ashik
Ayemun Hossain Ashik

Reputation: 510

  1. docker-compose build when you need to build or rebuild Docker images.

  2. docker-compose up to start and manage containers based on the images you've built or already have.

Upvotes: 1

zuazo
zuazo

Reputation: 5738

The following only builds the images, does not start the containers:

  • docker-compose build

The following builds the images if the images do not exist and starts the containers:

  • docker-compose up

If you add the --build option, it is forced to build the images even when not needed:

  • docker-compose up --build

The following skips the image build process:

  • docker-compose up --no-build

If the images aren't built beforehand, it fails.

The --no-cache option disables the Docker build cache in the image creation process. This is used to cache each layer in the Dockerfile and to speed up the image creation reusing layers (~ Dockerfile lines) previously built for other images that are identical.

Upvotes: 464

Related Questions