It seems you misinterpreted the documentation. The only requuirement of Docker Compose is docker since docker compose is another client for Docker which let’s you define everything in a yaml file. Compose v1 was originally written in Python, so you could install it in a Python virtual environment. Compose v2 was written in Go but for the same purpose.
I guess you found different examples for v1 and v2 but both versions can help you build a Docker image which requires a Dockerfile usually. v2 also supports the dockerfile_inline
option so you can write the content of the Dockerfile there. It is not a requirement of any compose. It is used by Docker to build an image and you can define that too in the compose file. Compose v2 also ignores the version keyword in the compose file.
Regarding the filename, since Compose v2 is a plugin for Docker, you can use it as docker compose
, but you could easily add an alias to that command as docker-compose
which was how the command of Compose v1 was named.
Usually you can follow a tutorial written for compose v1 and use docker compose
instead of docker-compose
.
I have a tutorial too in which I write about compose as well: Welcome to Learn Docker’s documentation! — Learn Docker documentation
I wrote it for compose v1. When I rewrote it for v2 I basically just replaced all docker-compose
commands with docker compose
and removed the version keyword from the compose files.
There are some features though that compose v2 doesn’t support. I wrote about one here: Docker Compose volumes, volume-only projects and init containers - DEV Community
You can read about other differences in the documentation: