Score:0

Move docker compose wordpress with local volume to new host with correct permission

at flag

I'm struggling to migrate / move my Docker Compoe project with Wordpress and Mysql to a new host.

My docker-compoye.yaml is as follows:

version: '3.1'

services:

  wordpress:
    image: wordpress
    restart: always
    ports:
      - 8099:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: root
      WORDPRESS_DB_PASSWORD: 'ahw5ai8gu9waewiuNgaithev7xie0jah'
      WORDPRESS_DB_NAME: wordpress
      WORDPRESS_DEBUG: 1
    depends_on:
      - db
    volumes:
      - .wordpress/plugins:/var/www/html/wp-content/plugins
      - .wordpress/themes:/var/www/html/wp-content/themes
      - .wordpress/uploads:/var/www/html/wp-content/uploads
      - ./wordpress.ini:/usr/local/etc/php/conf.d/wordpress.ini

  db:
    image: mysql:5.7
    restart: always
    ports:
      - 3306:3306
    environment:
      MYSQL_DATABASE: exampledb
      MYSQL_USER: exampleuser
      MYSQL_PASSWORD: examplepass
      MYSQL_ROOT_PASSWORD: ahw5ai8gu9waewiuNgaithev7xie0jah
    volumes:
      - .db:/var/lib/mysql

The directory structure is as follows:

drwxrwxr-x  8     999 mbecker 4,0K Mär  5 09:36 .db
-rwxrwxr-x  1 mbecker mbecker 2,5K Mär  2 16:39 docker-compose.yaml
drwxrwxrwx  6 mbecker mbecker 4,0K Apr 11  2021 .wordpress

I have done the following migration strategies to copy the complete directory / files to new host:

  • rsync the complete directory (and subdirectory) to the new hist
  • create a .tar of the local directory recursive, move to the new host, and extract it

However, the file permission for example in the volume / directory path .wordpress/plugins/changed from www-data to mbecker.

Starting the docker compose project on the new host results in the following Wordpress error:

Notice: Function WP_User_Query::query was called incorrectly. User queries should not be run before the plugins_loaded hook. Please see Debugging in WordPress for more information. (This message was added in version 6.1.1.) in /var/www/html/wp-includes/functions.php on line 5835

** The database data is imported correctly via import script ** The DNS names are pointed to the new IP and the Nginx reverse proxy directive is the same

Any ideas how to move the data from one host to another with correct file permission?

in flag
Just chown the volume directories.
mbecker avatar
at flag
Thanks for your reply! Haven't mentioned that I did it as well. Sorry! However, I've fixed it. I've missed that the docker-compose.yaml file haven't any tags for the wordpress image. So, it's pulled the latest which doesn't work. Specifying the correct tag (2 years ago) fixes the issues!
in flag
I wouldn't call that a "fix".
Score:0
at flag

In general, to fix permission issues doing a `sudo chown -R www-data:www-data folder" should work. In my case, I've missed to specify the image tag. Docker pulls automatically the image with the tag "latest"; having a running docker compose project for some years the "latest"-image is an image which is 2 years old. I've added the correct image tag to new migrated docker compose project and it's working.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.