Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

People also ask

What is the difference between docker compose build and up?

Description. Builds, (re)creates, starts, and attaches to containers for a service. Unless they are already running, this command also starts any linked services. The docker compose up command aggregates the output of each container (like docker compose logs --follow does).

Does docker compose cache?

Compose. If you're using Docker Compose, you can add the cache_from option to the compose file, which maps back to the docker build --cache-from <image> command when you run docker-compose build . To take advantage of BuildKit, make sure you're using a version of Docker Compose >= 1.25.

What is -- no cache in docker build?

Instead of using two separate lines for two consecutive RUN instructions, you can chain them to reduce the number of image layers and hence, reducing the possibility of a cache hit. If you don't want to allow the daemon to perform checks for cache at all, you can use the --no-cache option to do so.

Does docker compose up also build?

From your project directory, start up your application by running docker compose up . Compose pulls a Redis image, builds an image for your code, and starts the services you defined. In this case, the code is statically copied into the image at build time.


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.