Wordpress local development with remote DB works super slow - wordpress

I'm developing a woocommerce shop. To do that I use docker on my localhost, and DB which is located on the remote server. My local machine is windows 10 home (so i use docker toolbox). To set my locl env I use docker-compose.yaml, which you can see below:
version: '3'
services:
# Wordpress
wordpress:
image: wordpress:latest
ports:
- '8000:80'
restart: always
volumes: ['./:/var/www/html:delegated']
environment:
WORDPRESS_DB_HOST: WORDPRESS_DB_HOST
WORDPRESS_DB_NAME: 'WORDPRESS_DB_NAME'
WORDPRESS_DB_USER: 'WORDPRESS_DB_USER'
WORDPRESS_DB_PASSWORD: WORDPRESS_DB_PASSWORD
networks:
- wpsite
networks:
wpsite:
The above config works, but its super slow. Does anyone know how to speed this up?

Related

Error when trying to deploy WordPress database

I'm using the below stack to try and install WordPress on an ARM based computer but I keep getting an error in Portainer when I try and deploy the stack.
I'm running:
Docker Version: 5:20.10.17~3-0~debian-bullseye
Portainer version: 2.14.0
I get the following error:
failed to deploy a stack: db
Pulling wordpress
Pulling b84950154c18
Pulling fs layer b1ae07faadba
Pulling fs layer 46428e702eff
Pulling fs layer 0e775e0ed5a0
The list is actually much longer than this, I can paste the whole thing if necessary, but it is a lot of "Pulling fs layer {numbers and letters}"
Here is the stack I'm using:
version: '3.1'
services:
wordpress:
image: wordpress
restart: always
ports:
- 8484:80
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: gibblebreath
WORDPRESS_DB_PASSWORD: chickpea655
WORDPRESS_DB_NAME: wpdb
volumes:
- /srv/dev-disk-by-label-Files/Configs/WordPress:/var/www/html
links:
- db:db
db:
image: yobasystems/alpine-mariadb:latest
restart: always
environment:
MYSQL_DATABASE: wpdb
MYSQL_USER: gibblebreath
MYSQL_PASSWORD: chickpea655
MYSQL_RANDOM_ROOT_PASSWORD: '1'
volumes:
- /srv/dev-disk-by-label-Files/Databases/WordPress/db:/var/lib/mysql
volumes:
wordpress:
db:
I've tried other databse images, including mysql:latest, docker.io/bitnami/mariadb:10.7 and others but the same error occurs each time. I've also restarted both docker and portainer.
Any advice would be hugely appreciated.

Cannot complete wordpress setup aftern installing it with Docker Desktop + WSL2

I am trying to install wordpress using Docker Desktop and WSL2.
I was able to compose an image creating the following docker-compose.yml file and then running docker-compose up
version: '3.1'
services:
wordpress:
image: wordpress
restart: always
ports:
- 8080:80
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: exampleuser
WORDPRESS_DB_PASSWORD: examplepass
WORDPRESS_DB_NAME: exampledb
volumes:
- wordpress:/var/www/html
db:
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: exampledb
MYSQL_USER: exampleuser
MYSQL_PASSWORD: examplepass
MYSQL_RANDOM_ROOT_PASSWORD: '1'
volumes:
- db:/var/lib/mysql
volumes:
wordpress:
db:
(This is taken from the official wordpress image's page on docker hub. I have change the default environment variables for DB_USER, DB_PASSWORD and DB_NAME but they were set equal to MYSQL_USER, MYSQL_PASSWORD and MYSQL_DATABASE respectively.)
Back to Docker Desktop, I ran the container, which seems to work correctly because when I got to localhost:8080 I find Wordpress' first setup process. However, when I plug-in the database name, username, password and host that I used in the file I get the error "Error establishing a database connection".
I tried the following for as Database host, but none worked: localhost, localhost:8080, localhost:80 and db.
Any idea?

Restore a WordPress site on Docker.

I have a website which i want to containerised i tried following the steps mentioned on this link
i have my files copied to /var/www/html/example.com/src/ and also my docker-compose file looks like this :
version: '2'
services:
example_db:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: ${WP_DB_USER_PASSWORD}
MYSQL_DATABASE: ${WP_DB_NAME}
volumes:
- /var/lib/mysql:/docker-entrypoint-initdb.d/example.sql
container_name: example_db
restart: always
example:
depends_on:
- example_db
image: wordpress:5.0.0-php5.6-apache # we're using the image with php7.1
environment:
WORDPRESS_DB_PASSWORD: ${WP_DB_USER_PASSWORD}
WORDPRESS_DB_NAME: ${WP_DB_NAME}
container_name: example
ports:
- "1512:80"
restart: always
links:
- example_db:mysql
volumes:
- ./src:/var/www/html/docker/example.com/src/
i have my wordpress file in /www/html/docker/example.com/src/ and the db backup inside /src/docker/example.com/data/docker-entrypoint-initdb.d/lbdocker.sql
every time i acces the website it goes to the WordPress setup guide.
this is old but the issue is related to the $table_prefix
Your backup table prefix is different than the destination.
Update your config and it will work.
Fix

Can't access Wordpress installed in Docker container

New to Docker and not fully understand it, bear with me if my expressions are confusing/wrong. I have a Ubuntu box on Azure with public IP address assigned. Then I putty into the box and install apache, php. I also installed Docker and Docker-compose. I am following this official tutorial to install wordpress(on port 8000). When installation finishes I can see the default apache ubunto page at http://xxx.xxx.xxx.xxx, but I am unable to access the website at http://xxx.xxx.xxx.xxx:8000. What's the reason for not being able to access it? I can't find any relevant tutorial as most tutorials are doing it on localhost hence not referable. This is my docker-compose.yml file:
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
volumes:
db_data:
docker ps outputs following:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
07d669b9f95e phpmyadmin/phpmyadmin "/run.sh supervisord…" 10 hours ago Up 10 hours 9000/tcp, 0.0.0.0:8080->80/tcp wp_phpmyadmin_1
5ff939494739 wordpress:latest "docker-entrypoint.s…" 11 hours ago Up 11 hours 0.0.0.0:8000->80/tcp wp_wordpress_1
479826f7cfb8 mysql:5.7 "docker-entrypoint.s…" 11 hours ago Up 11 hours 3306/tcp, 33060/tcp wp_db_1
Solution: At last I managed to make it work by opening up the port in Azure.
The problem is not with docker as long as the ports are exposed and you can see the content in the host machine
the problem is probably with the host machine, which should expose 8000 port
i'm not familiar with Azure, but i'm guessing port 80 is exposed by default, so try changing
ports:
- "8000:80"
to
ports:
- "80:80"
and call the machine using port 80 (which is http default)

Docker Compose WordPress Volumes Appear Empty

I'm trying to set up a simple WordPress build using docker compose. However, when I build it, the volumes appear to be empty.
Here is my docker-compose.yml:
version: '3'
services:
wordpress:
image: wordpress
restart: always
ports:
- 8000:80
volumes:
- ./development:/var/www/html
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: password
depends_on:
- db
networks:
- wordpress-network
phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
ports:
- 8080:80
links:
- db:db
db:
image: mariadb:latest
ports:
- 127.0.0.1:3306:3306
command: [
'--default_authentication_plugin=mysql_native_password',
'--character-set-server=utf8mb4',
'--collation-server=utf8mb4_unicode_ci'
]
volumes:
- wp-data:/var/lib/mysql
environment:
MYSQL_DATABASE: wordpress
MYSQL_ROOT_PASSWORD: password
networks:
- wordpress-network
networks:
wordpress-network:
driver: bridge
volumes:
wp-data:
driver: local
Here is my local project structure, with theme stylesheet:
I run docker-compose to build the image:
docker-compose up -d --build
But when I open the build in my browser, it looks like the theme is empty:
This leads me to believe the volume is empty. I'd appreciate any help or insights into this issue, thank you.
In your docker-compose file you say ./wp-data:/var/lib/mysql which is host folder mapping (not volume) but in your docker-compose you define docker named volume called wp-data and if you want to use this volume you have to use it as wp-data:/var/lib/mysql. I would also suggest to remove ${PWD} because it might cause problem in sh

Resources