Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker Wordpress Setup with Volume for Theme Folder

I created a setup for a wordpress installation with docker-compose:

version: '3'

services:
  db:
    image: mysql:8.0
    container_name: db
    restart: unless-stopped
    env_file: .env
    volumes:
      - dbdata-dev:/var/lib/mysql
    command: '--default-authentication-plugin=mysql_native_password'
    networks:
      - rn-dev-network

  wordpress:
    depends_on:
      - db
    image: wordpress:5.5.3-fpm-alpine
    container_name: wordpress
    restart: unless-stopped
    env_file: .env
    environment:
      - WORDPRESS_DB_HOST=db:3306
      - WORDPRESS_DB_USER=$MYSQL_USER
      - WORDPRESS_DB_PASSWORD=$MYSQL_PASSWORD
      - WORDPRESS_DB_NAME=$MYSQL_DATABASE
    volumes:
      - ./wordpress/wp-content:/var/www/html/wp-content
      - ./wordpress/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
      - wordpress-dev:/var/www/html
    networks:
      - rn-dev-network

  webserver:
    depends_on:
      - wordpress
    image: nginx:1.15.12-alpine
    container_name: webserver
    restart: unless-stopped
    ports:
      - "80:80"
    volumes:
      - wordpress-dev:/var/www/html
      - ./nginx-conf:/etc/nginx/conf.d
    networks:
      - rn-dev-network

volumes:
  wordpress-dev:
  dbdata-dev:

networks:
  rn-dev-network:
    driver: bridge

Via FTP, I moved a theme into the wp-content/themes folder. The theme shows up on wordpress when starting the container, but it does not show any preview picture and is missing all pictures/assets when loading it.

I don't see what is missing. When I ssh into the container and check the folder, the volume is correctly linked and the wordpress theme is showing up in the correct folder.

Preview Screen of Wordpress Theme Setup

like image 669
retronexus Avatar asked Mar 04 '26 10:03

retronexus


1 Answers

You need to mount the image file to the nginx container, because static content is served via the nginx container. The Php container only executes the php.

webserver:
    depends_on:
      - wordpress
    image: nginx:1.15.12-alpine
    container_name: webserver
    restart: unless-stopped
    ports:
      - "80:80"
    volumes:
      - wordpress-dev:/var/www/html
      - ./wordpress/wp-content:/var/www/html/wp-content
      - ./nginx-conf:/etc/nginx/conf.d
    networks:
      - rn-dev-network
like image 178
Spirit Avatar answered Mar 06 '26 02:03

Spirit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!