Docker compose vs docker build

Hello,

How is docker compose different from docker build ?

Thx

They’re complete different and separate. docker build uses Dockerfiles to create docker images. docker compose uses docker-compose.yaml files to define how to deal with images and containers in a pretty general way. It can invoke the equivalent of “docker build”, it can deploy images in a way analogous to what Kubernetes does by setting up networks, port mappings and other things you need to run images in production. So it’s a general solution for deal with images.

Thks. I have a different question in docker and posting it here hoping to get answered.

When a docker image is pulled/run how do I find the base image its running on ?

There isn’t a simple way to get the name of the base image from a command. All you can get is the hash of the image’s layers. To get the base image, you need access to its Dockerfile. So for, say, nginx:alpine, you’d:

  • Go to Docker Hub and get a link to the docker-nginx github repo.
  • Find an appropriate Dockerfile (or in this case, the template for it).
  • See what FROM statement was used.