I'm trying to set up a Wordpress development environment using Podman and podman-compose.
Here's my docker-compose.yml file:
version: "3.9"
networks:
wordpress:
services:
wordpress:
container_name: wordpress
image: wordpress:php8.1-fpm-alpine
volumes:
- ./wordpress:/var/www/html:delegated
environment:
WORDPRESS_DB_HOST: mariadb
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: secret
WORDPRESS_DB_NAME: wordpress
networks:
- wordpress
I have other services, such as Nginx and MariaDB, but for simplicity's sake I'll use only wordpress in this example.
Problem is that I'm not able to add ./wordpress directory as a volume. If I do this with docker-compose
it works but with podman-compose
I get no such file or directory
error message. Same thing happens when I try to start the container directly with podman run
command.
If I replace the local directory with named volume, then it works:
version: "3.9"
networks:
wordpress:
volumes:
wordpress:
services:
wordpress:
container_name: wordpress
image: wordpress:php8.1-fpm-alpine
volumes:
- wordpress:/var/www/html:delegated
environment:
WORDPRESS_DB_HOST: mariadb
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: secret
WORDPRESS_DB_NAME: wordpress
networks:
- wordpress
However, this is not a working solution in my use case. I want to create a wordpress project template that I can clone into my computer, fire up the containers, install Wordpress and start editing the files in local directory.
Is there a way of achieving this behavior using Podman?
Just drop the :delegated
and use following template:
- ./wordpress:/var/www/html:rw,z
so the whole compose file would be:
version: "4"
services:
wordpress:
container_name: wordpress
image: wordpress:php8.1-fpm-alpine
volumes:
- ./wordpress:/var/www/html:rw,z
environment:
WORDPRESS_DB_HOST: mariadb
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: secret
WORDPRESS_DB_NAME: wordpress
networks:
- wordpress
networks:
wordpress:
volumes:
wordpress: