With docker I was able to run WordPress example for docker-compose on nearly every platform, without prior docker knowledge.
I look for a way to achieve the same with Podman.
In my case, to have a fast cross-platform way to setup a working WordPress installation for development.
As Podman is far younger, a valid answer in 2022 would also be: It is not possible, because… / only possible provided constraint X.
Still I would like to create an entry point for other people, who run into the same issue in the future.
I posted my own efforts below. Before I spend more hours debugging lots of small (but still solvable) issues, I wanted to find out if someone else faced the same problem and already has a solution. If you have, please clearly document its constraints.
My particular issue, as a reference
- I am on Ubuntu 20.04 and
podman -v
gives 3.4.2.
- docker/podman compose
- When I use
docker-compose up
with Podman back-end on docker’s WordPress.yml
-file, I run into the "duplicate mount destination" issue. podman-compose
is part of Podman 4.1.0, which is not available on Ubuntu as I write this.
- Red Hat example
- The example of Red Hat gives "Error establishing a database connection … contact with the database server at
mysql
could not be established". - A solution for the above does not work for me. share is likely a typo. I tried to replace with unshare.
- Cent OS example
- I found an example which uses pods instead of a docker-compose.yml file. But it is written for Cent OS.
- I modified the Cent OS example, see the script below. I get the containers up and running. However, WordPress is unable to connect to the database.
#!/bin/bash
# Set environment variables:
DB_NAME='wordpress_db'
DB_PASS='mysupersecurepass'
DB_USER='justbeauniqueuser'
POD_NAME='wordpress_with_mariadb'
CONTAINER_NAME_DB='wordpress_db'
CONTAINER_NAME_WP='wordpress'
mkdir -P html
mkdir -P database
# Remove previous attempts
sudo podman pod rm -f $POD_NAME
# Pull before run, bc: invalid reference format eror
sudo podman pull mariadb:latest
sudo podman pull wordpress
# Create a pod instead of --link. So both containers are able to reach each others.
sudo podman pod create -n $POD_NAME -p 80:80
sudo podman run --detach --pod $POD_NAME
-e MYSQL_ROOT_PASSWORD=$DB_PASS
-e MYSQL_PASSWORD=$DB_PASS
-e MYSQL_DATABASE=$DB_NAME
-e MYSQL_USER=$DB_USER
--name $CONTAINER_NAME_DB -v "$PWD/database":/var/lib/mysql
docker.io/mariadb:latest
sudo podman run --detach --pod $POD_NAME
-e WORDPRESS_DB_HOST=127.0.0.1:3306
-e WORDPRESS_DB_NAME=$DB_NAME
-e WORDPRESS_DB_USER=$DB_USER
-e WORDPRESS_DB_PASSWORD=$DB_PASS
--name $CONTAINER_NAME_WP -v "$PWD/html":/var/www/html
docker.io/wordpress
Also, I was a bit unsure where to post this question. If server fault or another stack exchange are a better fit, I will happily post there.
2
Answers
Actually, your code works with just small changes.
I removed the sudo’s and changed the pods external port to 8090, instead of 80. So now everything is running as a non-root user.
This is what worked for me: