Back to roadmaps docker-compose Course

Installing and Verifying Docker Compose CLI

Let us verify our local environment and review YAML file formatting rules.


1. Checking Your Compose Version (v1 vs v2)

In older setups, Docker Compose was a separate Python-based tool invoked using a hyphen: docker-compose.

In modern setups, Docker Compose is integrated directly into the Docker CLI as a subcommand: docker compose (without the hyphen).

Verify that you have the modern version installed:

docker compose version

If it returns Docker Compose version v2.x.x or higher, your CLI is up to date.


2. YAML Syntax Rules and Indentation

Docker Compose configuration files use YAML format. YAML relies on strict indentation rules:

  • Use Spaces, Not Tabs: Never use the Tab key to indent files. Always use spaces (usually 2 spaces per level).
  • Case Sensitivity: Key names are case-sensitive.
  • Colon Spacing: Colons marking keys must be followed by a space (for example, image: nginx, not image:nginx).

Here is a basic syntax example:

# docker-compose.yml
services:
  web-server:
    image: nginx:alpine
    ports:
      - "8080:80"
Published on Last updated: