Wordpress Docker

What’s the reasoning for setting it up this way instead of doing

#docker-compose.yml

services:

  wordpress:
    image: wordpress:php8.3-fpm
    restart: unless-stopped
    container_name: wordpress
    ports:
      - "8080:80"
    environment:
      WORDPRESS_DB_HOST: wordpress-db
      WORDPRESS_DB_USER: exampleuser
      WORDPRESS_DB_PASSWORD: examplepass
      WORDPRESS_DB_NAME: exampledb
    volumes:
      - ./wordpress:/var/www/html
      -./custom.ini
  db:
    image: mariadb:11.2.2
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: exampledb
      MYSQL_USER: exampleuser
      MYSQL_PASSWORD: examplepass
      MYSQL_RANDOM_ROOT_PASSWORD: '1'
    volumes:
      - ./db:/var/lib/mysql

networks:
  default:
    name: caddy_network
    external: true

#custom.ini

file_uploads = On
upload_max_filesize = 20056M
post_max_size = 20056M
memory_limit = 512M

in a separate directory:

#docker-compose.yml

services:

  caddy:
    image: caddy:2.7.6-alpine
    container_name: caddy
    hostname: caddy
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
      - "443:443/udp"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - ./caddy_config:/config
      - ./caddy_data:/data

networks:
  default:
    name: caddy_network
    external: true
#Caddyfile

wordpress.example.com {
    reverse_proxy wordpress:80
}

The php-fpm image does not have an HTTP server on port 80. Your example would not work.

Using php-fpm has lower overhead and has better performance than proxying from Caddy to an Apache server, since there’s only one HTTP server instead of two, and php-fpm performs better than Apache’s mod_php.

1 Like

I see. Thank you.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.