docker

The Docker engine, CLI, Compose v2, and buildx, with the login user in the docker group.

Installs a complete Docker setup: the engine, the CLI, the Compose v2 plugin, and buildx. This is the devtool behind “run my docker compose stack on a workstation”.

devtools:
  - name: docker

After that, docker, docker compose and docker buildx all work for the login user, without sudo. The version field is not used by this recipe.

What it does

On Debian and Ubuntu it declares Docker’s official apt repository (resolving your workstation’s distribution and codename automatically), installs docker-ce, docker-ce-cli, containerd.io, docker-buildx-plugin, and docker-compose-plugin, then enables and starts the daemon under systemd.

On Alpine it installs the distribution’s docker, docker-cli, docker-cli-compose, and docker-cli-buildx packages.

Afterwards it adds the workstation’s login user to the docker group, so docker ps works without sudo. You do not need to list docker under identity.groups.

On a workstation without systemd, the daemon is not started by this recipe; the runtime starts it instead.

When it counts as installed

The workstation only counts as having Docker when all three of these succeed: docker is on PATH, docker compose version works, and docker buildx version works. A workstation with the engine but no Compose plugin is not fully configured and the recipe re-runs. That is why Configured on a workstation that declares this devtool is a real promise that docker compose up will work.

Example

This config clones a repository that has a docker-compose.yml, installs Docker, brings the stack up, and forwards the app’s port to your laptop. It applies to every workstation labeled app: myapp.

apiVersion: workstations.ringleader.dev/v1
kind: WorkstationConfig
metadata:
  name: compose-box
  namespace: local
spec:
  selector:
    matchLabels:
      app: myapp
  identity:
    user: dev
  packages:
    - git
  devtools:
    - name: docker
  sources:
    - name: myapp
      git:
        url: https://github.com/acme/myapp.git
        ref: main
      path: /home/dev/src/myapp
  ports:
    - 8080
  defaultLocalBinding:
    enabled: true
    autoForward:
      forwardAll: true
  scripts:
    - name: compose-up
      phase: user
      content: |
        set -e
        cd ~/src/myapp
        docker compose up --build -d

Reading it top to bottom:

  • packages installs git, which sources needs to clone.
  • devtools installs Docker. Devtools install before sources and scripts, so docker compose exists the first time the script runs.
  • sources clones the repository into the dev user’s home. It clones once; add updatePolicy: latest to pull new commits on every setup run.
  • ports and defaultLocalBinding forward port 8080 to your laptop, so the app is at http://127.0.0.1:8080 once the stack is up.
  • scripts runs docker compose up once, as dev, who is in the docker group. To rebuild the stack whenever the code changes, set updatePolicy: latest on the source and add runPolicy: onChange and watchPaths: [/home/dev/src/myapp] to the script.

If you would rather start the stack yourself, leave out scripts, run rl shell <workstation>, and type docker compose up in the checkout.

Notes

  • Pair with kind to get a local Kubernetes cluster on top of the engine. kind needs Docker and should be declared after it.
  • On Debian and Ubuntu the packages arrive through the normal repository and package phases, so they interleave correctly with your own packages and packageRepositories.