Skip to content

Commit ebf6a5a

Browse files
committed
Add support for Podman
This adds support for a `GOVUK_DOCKER_CONTAINER_ENGINE` environment variable to define how to run GOV.UK Docker, primarily to allow using Podman instead of Docker (while still defaulting to the latter). It also adds the appropriate SELinux context to the `nginx-proxy` container to allow it to access host Docker (i.e. Podman) socket.
1 parent ff29d23 commit ebf6a5a

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

docker-compose.yml

+2
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ services:
133133
volumes:
134134
- /var/run/docker.sock:/tmp/docker.sock
135135
- ./nginx-proxy.conf:/etc/nginx/proxy.conf
136+
security_opt:
137+
- 'label=type:docker_t'
136138
networks:
137139
default:
138140
aliases:

docs/how-tos.md

+32
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,35 @@ connection), you can set the `SKIP_BRANCH_CHECKS` environment variable:
129129
```bash
130130
SKIP_BRANCH_CHECKS=1 make my-app
131131
```
132+
133+
## How to: Use Podman instead of Docker
134+
135+
> [!WARNING]
136+
> GOV.UK Docker was built for Docker (if the name didn't make that obvious!), so when leaving the
137+
> "golden path" you may experience unexpected issues that your peers can't help you with.
138+
>
139+
> For now, we recommend you only use another Linux container runtime if you are comfortable with
140+
> Linux and container technologies, and able/willing to resolve issues yourself.
141+
142+
If you prefer to use [Podman](https://podman.io/) instead of Docker to run and orchestrate your
143+
containers, you can set `GOVUK_DOCKER_CONTAINER_RUNTIME=podman` in your environment (for example, in
144+
your `.bashrc`).
145+
146+
Podman needs an external "compose provider" installed as a backing tool for `podman compose` (which
147+
itself is just a wrapper), and the ideal option is Docker's v2 Compose CLI plugin rather than the
148+
legacy `podman-compose` tool. You do not need Docker itself installed, and `podman compose` will
149+
pick up on the Docker Compose plugin automatically if installed, for example through:
150+
- Podman Desktop on macOS or Windows
151+
- your Linux distribution's package manager or Homebrew on macOS (check to make sure it's >= 2.x)
152+
- manually installing a release from [its repository](https://github.com/docker/compose)
153+
154+
There are two major gotchas relating to the Nginx proxy:
155+
- it needs to run on port 80, which under most circumstances requires root privileges to bind to on
156+
Linux, and
157+
- it requires a Docker-compatible socket to be mounted into the container, so is not compatible with
158+
daemonless approaches (like Podman's out-of-the-box architecture)
159+
160+
The easiest way to work around this is (more advanced approaches are available but left as an
161+
exercise for the reader):
162+
- on Linux, by setting up a Podman socket as root, and running GOV.UK Docker as root
163+
- on Mac, by using Podman Desktop and enabling all Docker Compatibility features

exe/govuk-docker

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
COMPOSE_FLAGS=("-f" "$(dirname "$0")/../docker-compose.yml")
1414
COMPOSE_FILES="$(dirname "$0")/../projects/*/docker-compose.yml"
15+
GOVUK_DOCKER_CONTAINER_RUNTIME="${GOVUK_DOCKER_CONTAINER_RUNTIME:-docker}"
1516

1617
for file in $COMPOSE_FILES; do
1718
COMPOSE_FLAGS+=("-f" "$file")
@@ -21,5 +22,5 @@ if ! "$(dirname "$0")"/govuk-docker-version >/dev/null; then
2122
read -rp "Press enter to continue..."
2223
fi
2324

24-
>&2 echo "docker compose -f [...] $*"
25-
docker compose "${COMPOSE_FLAGS[@]}" "$@"
25+
>&2 echo "${GOVUK_DOCKER_CONTAINER_RUNTIME} compose -f [...] $*"
26+
${GOVUK_DOCKER_CONTAINER_RUNTIME} compose "${COMPOSE_FLAGS[@]}" "$@"

0 commit comments

Comments
 (0)