Updating Wordpress

I’ve used Brad Traversy’s YT video ‘Quick Wordpress Setup With Docker’ to get a WP up and running (see code below). But there is still a lot I don’t understand. I’ve got my WP site up and running but I’ve got WP telling me there are updates available, before I ask my main question, I’d like to clear something up.

I’ve got a local folder which is mapped to another folder in the container and they sync up. Am I right in assuming that if WP updates (via my WP Admin console http://localhost:8000/wp-admin), it’s actually updating my local folder, which in turn will update WP in the container since they are set up to sync with each other?

http://localhost:8000/ gives me access to the site.

Currently if I try to update this is what I see in the WP console

docker-compose.yaml ->

version: '3'

services: 

    #######  Database service  #######

    db:

        image: mysql:5.7

        volumes:

            # This gives us persistence

            - db_data:/var/lib/mysql

        # if the server reboots the container restarts

        restart: always

        # define your mysql environment variables

        environment:

            MYSQL_ROOT_PASSWORD: password

            MYSQL_DATABASE: wordpress

            MYSQL_USER: wordpress

            MYSQL_PASSWORD: wordpress

        networks:

            - wpsite

        

    #######  phpmyadmin service  #######

    phpmyadmin:

        depends_on: 

            - db

        image: phpmyadmin/phpmyadmin

        restart: always

        ports:

            - '8080:80'

        environment: 

            PMA_HOST: db

            # as above in the db service

            # your phymyadmin login is root/password

            MYSQL_ROOT_PASSWORD: password

        networks:

            - wpsite

    #######  Wordpress service  #######

    wordpress:

        depends_on:

            - db

        image: wordpress:latest

        ports:

            # local:8000, container:80

            - '8000:80'

        restart: always

        # okay so we want the WP install in the container to sync locally here

        # Mapping './' (local current folder) to '/var/www/html' (container's web root folder as we're using apache)

        volumes: ['./:/var/www/html']

        environment: 

            # the host is going to be the db service by mysql above, port 3306 is the default for mysql

            # we've already setup the DB user above

            WORDPRESS_DB_HOST: db:3306

            WORDPRESS_DB_USER: wordpress

            WORDPRESS_DB_PASSWORD: wordpress

        networks:

            - wpsite

            # map the volume of db_data (in service db above) and the network of 'wpsite'

networks: 

    wpsite:

volumes:

    db_data:

# Now go and run docker-compose up -d

After watching countless videos I found an answer:

  • To update WP to a later version go into your yml file set the version you want.

  • Then just issue the following command:
    docker-compose up -d wordpress

  • Then go into your WP admin console and select ‘upgrade’

Simples

It’s easier solution.

You have to edit wp-config.php file by add define('FS_METHOD','direct'); to the end of file.
Save the file and run update. From now, you don’t need FTP server to update your WordPress.
Remember! Before update make a backup :slight_smile:

1 Like

How can setup WordPress to docker and what is the process.

on your yml file, you don’t need to map the whole wordpress folder
volumes: [‘./:/var/www/html’]

wp-content folder is enough
volumes: [‘./wp-content:/var/www/html/wp-content’]

And to update wordpress, especially if you are using the latest tag, issue the following command

docker pull wordpress

This will update the wordpress image on your machine
Finally, spin up the service by
docker compose up -d