Docker Community Forums

Share and learn in the Docker community.

Docker Desktop breaks WordPress after restart

Once I restart Docker Desktop, my newly installed custom theme as well as newly installed plugins no longer work in my WordPress installation running on official WordPress docker image. If I restart only containers, not the Docker Desktop, no issues occur (until I restart Docker Desktop).

The following message appears in the admin panel in my WordPress after the Docker Desktop restart:

The active theme is broken. Reverting to the default theme.

The same theme works perfectly fine on non-docker WordPress installations.

My docker-compose.yaml:

version: '3'

services:
  # Database
  db:
    image: mysql:5.7
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress
    networks:
      - wpsite
  # Wordpress
  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    ports:
      - '8000:80'
    restart: always
    volumes: ['./:/var/www/html']
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
    networks:
      - wpsite
networks:
  wpsite:
volumes:
  db_data:

Is it possible that you have a firewall installed that blocks the Docker network after the restart, so the volume can’t be mounted? This happens for example if you use Kaspersky.

When I have restart: always in my docker-compose.yaml, the volumes don’t mount after the Docker restart. However, if I set the restart to no and start containers manually after the Docker restart, the volumes mount properly.

This issue seems to have been opened two years ago: github.com/docker/for-win/issues/584, but not yet fixed.

Thanks for the link. Didn’t know there is an issue on Github, I just know from my own experience that it’s better to give Docker Desktop enough time to wake up. The explanation is: “The host-mount volume is not available immediately upon Docker start but becomes available a few seconds later.”

1 Like

Well, the issue has been opened for two years already.

Yes, I have seen that post. When the host mount is not available, the docker reverts wordpress to its original state in the client folder and my additions to wordpress is lost as the result.

Thank you for your responses!