Skip to content

Commit 4e4d95f

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 4e4d95f

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

docker-compose.yml

Lines changed: 2 additions & 0 deletions
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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,21 @@ 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+
If you prefer to use [Podman](https://podman.io/) instead of Docker to run and orchestrate your
136+
containers, you can set `GOVUK_DOCKER_CONTAINER_RUNTIME=podman` in your environment (for example, in
137+
your `.bashrc`).
138+
139+
Note that Podman needs an external "compose provider" installed as a backing tool for `podman
140+
compose` (which itself is just a wrapper), and the ideal option is Docker's v2 Compose CLI plugin.
141+
You do not need Docker itself installed, and `podman compose` will pick up on the plugin
142+
automatically if installed, for example through:
143+
- Podman Desktop on macOS or Windows
144+
- your Linux distribution's package manager or Homebrew on macOS (check to make sure it's >= 2.x)
145+
- manually installing a release from [its repository](https://github.com/docker/compose)
146+
147+
GOV.UK Docker works by running an Nginx container on port 80, which requires root privileges to bind
148+
to. You will need to run `govuk-docker` as root on Linux, or if you are using Podman Machine, have
149+
it configured appropriately (this is taken care of for you when using Podman Desktop).

exe/govuk-docker

Lines changed: 3 additions & 2 deletions
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)