Issue migrating wordpress to docker (solved)

HI

Currently trying to migrate a copy of wordpress to a docker container, currently im using this tutorial Move Wordpress site into Docker and publish it on remote site using Nginx. | by Borama Apps | Medium

and this is the logs im getting

the issue is that when i try to access the website it shows as if its a fresh install of wordpress

This is my docker compose file

and my env file

root@dockers:/wordpress# cat .env
MYSQL_ROOT_PASSWORD=somerootpassword
MYSQL_DATABASE=wordpress
MYSQL_USER=wordpress
MYSQL_PASSWORD=wordpress
root@dockers:/wordpress# cat docker-compose.yml
version: '3.3'

services:
   db:
     image: mysql:5.7
     volumes:
       - /wordpress/wordpress.sql:/docker-entrypoint-initdb.d/init.sql # prepopulate database
       - /wordpress/db_data:/var/lib/mysql # persist database data inside docker storage
     restart: always
     env_file:
      - .env
     environment:
      DOCKER_COMPOSE_YML_LOCATION: ${PWD}
     container_name: wp_db

   phpmyadmin:
     image: phpmyadmin/phpmyadmin
     restart: always
     ports:
       - "8084:80"
     environment:
       PMA_HOST: db
       MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
       DOCKER_COMPOSE_YML_LOCATION: ${PWD}
     container_name: wp_phpmyadmin
   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "8083:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: ${MYSQL_USER}
       WORDPRESS_DB_PASSWORD: ${MYSQL_PASSWORD}
       WORDPRESS_DB_NAME: ${MYSQL_DATABASE}
       DOCKER_COMPOSE_YML_LOCATION: ${PWD}
     volumes:
       - /wordpress/wp-content:/var/www/html/wp-content
     container_name: wp_wordpress
volumes:
    db_data: {}
root@dockers:/wordpress# docker-compose up
Creating network "wordpress_default" with the default driver
Creating volume "wordpress_db_data" with default driver
Creating wp_phpmyadmin ... done
Creating wp_db         ... done
Creating wp_wordpress  ... done
Attaching to wp_db, wp_phpmyadmin, wp_wordpress
wp_db         | 2022-06-10 18:38:38+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.38-1debian10 started.
wp_db         | 2022-06-10 18:38:38+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
wp_db         | 2022-06-10 18:38:38+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.38-1debian10 started.
wp_db         | 2022-06-10T18:38:39.315409Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
wp_db         | 2022-06-10T18:38:39.316677Z 0 [Note] mysqld (mysqld 5.7.38) starting as process 1 ...
wp_db         | 2022-06-10T18:38:39.318791Z 0 [Note] InnoDB: PUNCH HOLE support available
wp_db         | 2022-06-10T18:38:39.318802Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
wp_db         | 2022-06-10T18:38:39.318805Z 0 [Note] InnoDB: Uses event mutexes
wp_db         | 2022-06-10T18:38:39.318808Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
wp_db         | 2022-06-10T18:38:39.318811Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
wp_db         | 2022-06-10T18:38:39.318814Z 0 [Note] InnoDB: Using Linux native AIO
wp_db         | 2022-06-10T18:38:39.319003Z 0 [Note] InnoDB: Number of pools: 1
wp_db         | 2022-06-10T18:38:39.319085Z 0 [Note] InnoDB: Not using CPU crc32 instructions
wp_db         | 2022-06-10T18:38:39.320547Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
wp_db         | 2022-06-10T18:38:39.327501Z 0 [Note] InnoDB: Completed initialization of buffer pool
wp_db         | 2022-06-10T18:38:39.329171Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
wp_db         | 2022-06-10T18:38:39.340418Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
wp_db         | 2022-06-10T18:38:39.360306Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
wp_db         | 2022-06-10T18:38:39.360422Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
wp_db         | 2022-06-10T18:38:39.371563Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
wp_db         | 2022-06-10T18:38:39.372232Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
wp_db         | 2022-06-10T18:38:39.372371Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
wp_db         | 2022-06-10T18:38:39.372622Z 0 [Note] InnoDB: Waiting for purge to start
wp_db         | 2022-06-10T18:38:39.422784Z 0 [Note] InnoDB: 5.7.38 started; log sequence number 23635231
wp_db         | 2022-06-10T18:38:39.423023Z 0 [Note] Plugin 'FEDERATED' is disabled.
wp_db         | 2022-06-10T18:38:39.426748Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
wp_db         | 2022-06-10T18:38:39.429391Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
wp_db         | 2022-06-10T18:38:39.429423Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
wp_db         | 2022-06-10T18:38:39.429440Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
wp_db         | 2022-06-10T18:38:39.429454Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
wp_db         | 2022-06-10T18:38:39.429896Z 0 [Warning] CA certificate ca.pem is self signed.
wp_db         | 2022-06-10T18:38:39.429945Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
wp_db         | 2022-06-10T18:38:39.430367Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
wp_db         | 2022-06-10T18:38:39.430474Z 0 [Note] IPv6 is available.
wp_db         | 2022-06-10T18:38:39.430503Z 0 [Note]   - '::' resolves to '::';
wp_db         | 2022-06-10T18:38:39.430535Z 0 [Note] Server socket created on IP: '::'.
wp_db         | 2022-06-10T18:38:39.431140Z 0 [Note] InnoDB: Buffer pool(s) load completed at 220610 18:38:39
wp_db         | 2022-06-10T18:38:39.433103Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
wp_db         | 2022-06-10T18:38:39.447271Z 0 [Note] Event Scheduler: Loaded 0 events
wp_db         | 2022-06-10T18:38:39.447447Z 0 [Note] mysqld: ready for connections.
wp_db         | Version: '5.7.38'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)
wp_wordpress  | WordPress not found in /var/www/html - copying now...
wp_phpmyadmin | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.22.0.3. Set the 'ServerName' directive globally to suppress this message
wp_phpmyadmin | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.22.0.3. Set the 'ServerName' directive globally to suppress this message
wp_phpmyadmin | [Fri Jun 10 18:38:39.111234 2022] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.53 (Debian) PHP/8.0.19 configured -- resuming normal operations
wp_phpmyadmin | [Fri Jun 10 18:38:39.111272 2022] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
wp_wordpress  | WARNING: '/var/www/html/wp-content/plugins/akismet' exists! (not copying the WordPress version)
wp_wordpress  | WARNING: '/var/www/html/wp-content/themes/twentytwenty' exists! (not copying the WordPress version)
wp_wordpress  | WARNING: '/var/www/html/wp-content/themes/twentytwentyone' exists! (not copying the WordPress version)
wp_wordpress  | WARNING: '/var/www/html/wp-content/themes/twentytwentytwo' exists! (not copying the WordPress version)
wp_wordpress  | Complete! WordPress has been successfully copied to /var/www/html
wp_wordpress  | No 'wp-config.php' found in /var/www/html, but 'WORDPRESS_...' variables supplied; copying 'wp-config-docker.php' (WORDPRESS_DB_HOST WORDPRESS_DB_NAME WORDPRESS_DB_PASSWORD WORDPRESS_DB_USER)
wp_wordpress  | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.22.0.4. Set the 'ServerName' directive globally to suppress this message
wp_wordpress  | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.22.0.4. Set the 'ServerName' directive globally to suppress this message
wp_wordpress  | [Fri Jun 10 18:38:39.781412 2022] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.53 (Debian) PHP/7.4.30 configured -- resuming normal operations
wp_wordpress  | [Fri Jun 10 18:38:39.781454 2022] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
wp_wordpress  | 192.168.100.17 - - [10/Jun/2022:18:38:51 +0000] "GET / HTTP/1.1" 200 9930 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
wp_wordpress  | 192.168.100.17 - - [10/Jun/2022:18:38:52 +0000] "GET /favicon.ico HTTP/1.1" 302 408 "http://192.168.2.253:8083/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
wp_wordpress  | 192.168.100.17 - - [10/Jun/2022:18:39:43 +0000] "-" 408 0 "-" "-"

Thanks for using code blocks :slight_smile: however I edited your post, highlight the different parts of the code separately. This way we can see where are your mentioned logs and other parts. Consider using this method next time, it helps a lot to understand the question

Have you checked that if you successfully imported the exported data into the new database?

Thank you for the reply, will keep that in mind,
as for the data
correct i went to the phpmyadmin and check the data and it was correctly uploaded, i also imported just to make sure thought the phpmyadmin but not sure why the wp-content now showing correctly or it seems that its grabbing wp-content from another location

Imgur

Imgur

so i reinstalled everything again and it seems that now it shows a different error which im getting


# Forbidden

You don't have permission to access this resource.Server unable to read htaccess file, denying access to be safe

i deleted the .htaccess file but still the same issue

Your picture shows that /var/www/html is on a volume. The definition is in the Dockerfile:

This is what you need to remember when you want use a new image because the content of that volume will not change. This is where you will most likely have proper permissions, since the content of the image will be copied here with the original permissions when you start the container or sometimes it is populated only by the process in the container itself.

Then you can mount folders over the volume as you did:

wp-content can be empty in the volumeā€™s _data folder but it will not be empty from the containerā€™s point of view. These folders however need to have proper permissions before you start the container. make sure it is owned by www-data. Since you have www-data on your host too (I am saying it based on your pictures), you can run

chown -R www-data:www-data /wordpress/wp-content

from your host as root. I donā€™t use wordpress recently so I canā€™t tell you the exact solutions, but proper permissions, right mount points and volumes are important.

You could also try this migration process without a container, if you havenā€™t done it yet. Maybe there is something else that causes the problem besides the fact that you use containers.

i doubt that deleting a file could solve the permission issue of that file, unless that was changed somehow after the installation and it is automatically recreated. I donā€™t know if thatā€™s true.

3 Likes

Thank you so much it was the permission issue