Docker Compose vs. Dockerfile – which is better?

Technology CommunityCategory: DockerDocker Compose vs. Dockerfile – which is better?
VietMX Staff asked 3 years ago

The answer is neither.

Docker Compose (herein referred to as compose) is a tool for defining and running multi-container Docker applications and will use the Dockerfile if you add the build command to your project’s docker-compose.yml. Your Docker workflow should be to build a suitable Dockerfile for each image you wish to create, then use compose to assemble the images using the build command.

You can specify the path to your individual Dockerfiles using build /path/to/dockerfiles/blah where /path/to/dockerfiles/blah is where blah’s Dockerfile lives.

In your workflow, you could add a Dockerfile for each part of the system and configure it that each part could run individually. Then you add a docker-compose.yml to bring them together and link them.