Skip to content

Commit dee8bb1

Browse files
committed
PXC-5141 - [DOCS] - [feedback] It doesn't work with podman compose 8.4
modified: docs/docker-compose.md
1 parent a94d125 commit dee8bb1

1 file changed

Lines changed: 53 additions & 3 deletions

File tree

docs/docker-compose.md

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,54 @@ We gather [Telemetry data](telemetry.md) in the Percona packages and Docker imag
1010

1111
This guide shows you how to deploy a three-node Percona XtraDB Cluster 8.4 using Docker Compose. You generate SSL certificates on the first node and copy them to the other two nodes to enable secure communication.
1212

13+
## Using Podman instead of Docker
14+
15+
Podman can be used as an alternative to Docker because it supports the same container images. It is not fully compatible with Docker Compose. To run this deployment with Podman, you may need to use `podman compose` or podman-compose, depending on your environment and configuration.
16+
17+
Podman uses a different architecture (for example, pods and rootless containers). As a result, networking, volume mounts, and service behavior may differ from Docker Compose. This deployment has been tested with Docker Compose. If you use Podman, verify that the cluster operates as expected before using it in production.
18+
19+
You can use the same Compose file and workflow with [Podman](https://podman.io/). Use Podman 4.1 or later; the built-in `podman compose` subcommand requires 4.1 or newer. With older Podman, use the separate podman-compose tool. Then:
20+
21+
* Prerequisites: Podman and Podman Compose (for example, `pip install podman-compose` or your distro’s package) if you are not using built-in `podman compose`. For rootless Podman, ensure the user has enough resources (for example, `sysctl user.max_user_namespaces` and subuid/subgid ranges).
22+
23+
* Commands: Replace `docker compose` with `podman compose` or `podman-compose`, and `docker exec` with `podman exec`. Examples:
24+
25+
* Start node 1: `podman compose up -d pxc1` (or `podman-compose up -d pxc1`)
26+
27+
* Start other nodes: `podman compose up -d pxc2 pxc3`
28+
29+
* Validate: `podman exec -it pxc1 mysql -uroot -p${MYSQL_ROOT_PASSWORD} -e "SHOW STATUS LIKE 'wsrep_cluster_size';"`
30+
31+
* Directory structure: The same layout (`pxc-cluster/` with `certs/`, `conf.d/`, and `init/`) works with Podman. Run `podman compose` from the project directory (for example, `pxc-cluster/`) so the relative volume paths in the Compose file resolve correctly.
32+
33+
* Compose file: The `docker-compose.yml` in this guide works as-is with Podman; the `bridge` network and volume mounts are supported. For rootless Podman, see the volume mount options below.
34+
35+
### Handling rootless permissions (most important for Podman)
36+
37+
In Docker, the daemon runs as root and can override file permissions. In Podman, if you run as a normal user, the MySQL process inside the container (usually UID 1001 or 999) may not have permission to read the files you created on the host. Ensure the files are readable by the container. On systems with SELinux, use the `:Z` (private) or `:z` (shared) mount option so Podman relabels the volume for the container. In your `docker-compose.yml`, use:
38+
39+
```text
40+
volumes:
41+
- ./certs:/etc/mysql/certs:ro,Z
42+
- ./conf.d:/etc/percona-xtradb-cluster.conf.d:ro,Z
43+
```
44+
45+
Apply the same volume options to every service (pxc1, pxc2, pxc3). Without `:Z` or `:z`, the container may fail to read certs or config when running rootless on SELinux.
46+
47+
### podman-compose vs docker-compose
48+
49+
* If you use podman-compose (the Python tool): It reads the directory structure and `.env` file the same way Docker does.
50+
51+
* If you use docker-compose with the Podman socket: This is often more stable for PXC. Set `DOCKER_HOST` to point at the Podman socket (for example, `unix:///run/user/$(id -u)/podman/podman.sock`) so `docker compose` talks to Podman.
52+
53+
### Network considerations
54+
55+
PXC uses specific ports for cluster communication (4567, 4568, 4444). Podman uses different networking (netavark or CNI). If nodes cannot find each other:
56+
57+
* Keep using a named network in the Compose file (for example, `pxcnet`) so Podman can resolve container names (pxc1, pxc2, pxc3).
58+
59+
* If problems persist, try setting `network_mode: slirp4netns` on the services, or run the stack rootful to use the default bridge.
60+
1361
The following procedure describes setting up a simple 3-node cluster
1462
for evaluation and testing purposes. Do not use these instructions in a
1563
production environment because the MySQL certificates generated in this
@@ -19,7 +67,7 @@ In a production environment, you should generate and store the certificates to b
1967

2068
## Prerequisites
2169

22-
* Docker and Docker Compose installed
70+
* Docker and Docker Compose installed (or Podman 4.1 or later and Podman Compose; see [Using Podman instead of Docker](#using-podman-instead-of-docker))
2371

2472
* At least 3 GB of memory per container
2573

@@ -207,23 +255,25 @@ This structure helps manage configuration files, TLS/SSL certificates, and setup
207255
```shell
208256
docker compose up -d pxc1
209257
```
258+
(With Podman: `podman compose up -d pxc1` or `podman-compose up -d pxc1`.)
210259
211260
Then, start the remaining nodes:
212261
213262
214263
```shell
215264
docker compose up -d pxc2 pxc3
216265
```
266+
(With Podman: `podman compose up -d pxc2 pxc3` or `podman-compose up -d pxc2 pxc3`.)
217267
218268
7. Validate the Cluster
219269
220-
Check the status of each node:
270+
Check the status of each node. Exact commands (run from the host; use the same password as in your `.env`):
221271
222-
223272
```shell
224273
docker exec -it pxc1 mysql -uroot -p${MYSQL_ROOT_PASSWORD} -e "SHOW STATUS LIKE 'wsrep_cluster_size';"
225274
docker exec -it pxc2 mysql -uroot -p${MYSQL_ROOT_PASSWORD} -e "SHOW STATUS LIKE 'wsrep_cluster_status';"
226275
```
276+
(With Podman: use `podman exec` instead of `docker exec`.)
227277
228278
You should see all three nodes joined and synchronized.
229279

0 commit comments

Comments
 (0)