I'm running a php-fpm wordpress container.
The wordpress source files are mounted in a named volume "wordpress" shared with the Nginx container.
Everything is running well except when i need to update wordpress to a new version. The code inside the named volume persists. It is normal for a named volume...
I could manually delete the volume but there must be a better way.
My dockerfile:
FROM wordpress:4.9.5-php5.6-fpm-alpine
My docker-compose.yml
version: '3.1'
services:
  php:
    build: ./docker/php/
    restart: unless-stopped
    volumes:
      - wordpress:/var/www/html
      - ./web/wp-content/:/var/www/html/wp-content/
      - ./web/wp-config.php:/var/www/html/wp-config.php
    environment:
      - DEBUG=${DEBUG:-0}
      - MYSQL_USER=$MYSQL_USER
      - MYSQL_PASSWORD=$MYSQL_PASSWORD
      - MYSQL_DATABASE=$MYSQL_DATABASE
  nginx:
    image: nginx:1-alpine
    restart: unless-stopped
    expose:
      - 80
    volumes:
      - wordpress:/var/www/html
      - ./web/wp-content/:/var/www/html/wp-content/
      - ./docker/nginx/site.conf:/etc/nginx/conf.d/default.conf
      - ./docker/nginx/wordpress.conf:/etc/nginx/wordpress.conf
    environment:
      - VIRTUAL_HOST=localhost
  mysql:
    image: mysql:5.6
    restart: unless-stopped
    environment:
      - MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD
      - MYSQL_USER=$MYSQL_USER
      - MYSQL_PASSWORD=$MYSQL_PASSWORD
      - MYSQL_DATABASE=$MYSQL_DATABASE
    volumes:
      - mysql:/var/lib/mysql
volumes:
  wordpress: {}
  mysql: {}
networks:
  default:
    external:
      name: wordpress
Looking forward to reading your suggestions
Thank you
My answer applied to the official docker wordpress image. So probably off topic but might help someone.
If you are using docker-compose you can pull the latest image using this command.
docker pull wordpress
I believe this will update your core docker image. Any other local project which you docker-compose up -d with this yml image setting as this will use the latest update.
  services:
    wordpress:
      image: wordpress:latest
If you currently running the image will you need to docker-compose down and  docker-compose up -d to invoke the update.
Wordpress seems to have addressed this under this issue.
I notice you are using a custom wp-config.php. Most likely, you can use the WORDPRESS_CONFIG_EXTRA for this rather than mounting wp-config.php.
Theoretically (per the link above), updating the image should update the database, but I have not confirmed.
Based on this, my stack.yml/docker-compose.yml looks like this:
    environment:
      WORDPRESS_CONFIG_EXTRA: |
        define( 'AUTOMATIC_UPDATER_DISABLED', true );
    volumes:
      - "./themes:/var/www/html/wp-content/themes/"
      - "./plugins:/var/www/html/wp-content/plugins/"
      - "./uploads:/var/www/html/wp-content/uploads/"
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With