Sid Patel
Sid Patel

Reputation: 173

What is the difference b/w a docker image generated by docker-compose build vs docker build?

While building a docker image, image id is different if the image is built using docker-compose build vs docker build. The env has different hostname.

What else is different? Why images are different?

Upvotes: 6

Views: 560

Answers (2)

Armin Braun
Armin Braun

Reputation: 3683

There are no differences between the actual image that gets built between docker-compose build and a "manual" docker build in terms of the contents of the image.

The difference is only in naming/tagging of the build result, which docker-compose does automatically for you. Other than that, the docker-compose build is no different behind the scenes and simply a wrapper for the normal docker build.

Upvotes: 2

Robert
Robert

Reputation: 36863

In addition to the naming difference, there could be difference in the resulting image if the parameters of the builds are different: the build: section of the docker-compose.yml and the command line parameters of the docker build command. For example the --build-args can be different.

Upvotes: 1

Related Questions