I had the pleasure to setup WordPress in a docker-compose container for my staging website. Worked like a charm.
Now I am ready to create the production version, so I duplicated the docker-compose file and amended it with different ports and different services names.
However, when I run the lot, the WordPress container keeps rebooting and throwing the error:
MySQL Connection Error: (2002) Connection refused
Warning: mysqli::__construct(): (HY000/2002): Connection refused in Standard input code on line 22
I am not really sure why it is not connecting, I am doing the exact same thing as the other docker containers:
c63395d420dc wordpress:latest "docker-entrypoint.s…" 3 minutes ago Up 10 seconds 0.0.0.0:8003->80/tcp foo-wp-prod
d58eeeede519 mysql:5.7 "docker-entrypoint.s…" 3 minutes ago Up 3 minutes 33060/tcp, 127.0.0.1:3310->3306/tcp foo-wp-db-prod
b6054525bbd9 wordpress:latest "docker-entrypoint.s…" 5 weeks ago Up 1 second 0.0.0.0:8001->80/tcp foo-wp-staging
e25c3d185152 mysql:5.7 "docker-entrypoint.s…" 6 weeks ago Up 7 seconds 127.0.0.1:3306->3306/tcp, 33060/tcp foo-wp-db-staging
I have the docker-compose file here:
version: '3.3'
services:
db_prod:
image: mysql:5.7
container_name: foo-wp-db-prod
volumes:
- db_data_prod:/var/lib/mysql
ports:
- 127.0.0.1:3310:3306
restart: always
environment:
MYSQL_ROOT_PASSWORD: -------
MYSQL_DATABASE: -----
MYSQL_USER: ------
MYSQL_PASSWORD: --------
wordpress_prod:
depends_on:
- db_prod
image: wordpress:latest
container_name: foo-wp-prod
ports:
- "8003:80"
restart: always
environment:
WORDPRESS_DB_HOST: db_prod:3310
WORDPRESS_DB_USER: -----
WORDPRESS_DB_PASSWORD: -----
WORDPRESS_DB_NAME: -----
volumes:
- /home/ubuntu/git/prod/wp-content/themes/foo_theme:/var/www/html/wp-content/themes/foo_theme
- /home/ubuntu/git/prod/wp-content/uploads:/var/www/html/wp-content/uploads
volumes:
db_data_prod:
The database is there, the users are there, I can connect remotely to it, so it seems to be the connection between the 2 containers that is not working for this copy of a working setup.
Any chance someone knows what is going on?
Hosting Environment
AWS VPS
1 GB RAM
Ubuntu (latest)
Related
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.
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?
I have been working in this bitnami-wordpress-docker and still stuck on configuration. I have seen few tutorials in which the command docker-compose up -d create bunch of files inside the folder and later localhost:8000 lands to the admin part of the wordpress. But things are not being simple for me.
Here is my docker-compose.yml file.
version: '3'
services:
mariadb:
user: root
image: 'bitnami/mariadb:10.3'
volumes:
- 'mariadb_data:/bitnami'
restart: always
environment:
- MARIADB_USER=bn_wordpress
- MARIADB_DATABASE=bitnami_wordpress
- ALLOW_EMPTY_PASSWORD=yes
networks:
- wpsite
wordpress:
image: 'bitnami/wordpress:latest'
ports:
- '8000:80'
restart: always
volumes:
- 'wordpress_data:/bitnami'
depends_on:
- mariadb
environment:
- MARIADB_HOST=mariadb
- MARIADB_PORT_NUMBER=3306
- WORDPRESS_DATABASE_USER=bn_wordpress
- WORDPRESS_DATABASE_NAME=bitnami_wordpress
- ALLOW_EMPTY_PASSWORD=yes
networks:
- wpsite
phpmyadmin:
depends_on:
- mariadb
image: phpmyadmin/phpmyadmin
restart: always
ports:
- '8080:80'
environment:
PMA_HOST: mariadb
MYSQL_ROOT_PASSWORD: password
networks:
- wpsite
networks:
wpsite:
volumes:
mariadb_data:
driver: local
wordpress_data:
driver: local
The command I mentioned above is creating containers.
When I try localhost:8000, noting shows. But when localhost:8080 lands me to phpmyadmin page.
Can anybody please tell me how can I setup this Bitnami wordpress using docker. It starts getting frustrating for me.
Thank You.
Under windows, it often happens to me that some ports are occupied;)
I do that:
I start powershell or cmd as admin
running netstat -aon | findstr 8080 the last number is the port
I get TCP 0.0.0.0:8080 0.0.0.0.0 LIETENIN 3428
run taskkill /f /pid 3428
And I'm also using the vscode plugin vscode-docker to use for removing all contaners and images.
Take a look at my example of docker+wordpress+xdebug maybe something will come in handy ;)
I started working with Docker for WordPress. I followed the docker documentation to get it up and running:
https://docs.docker.com/compose/wordpress/
I added volumes for the plugin & theme directory.
When ran the command docker-compose up -d the first time and went to http://localhost:8000/ i saw the installation of WordPress. When i rebooted my PC and started the services again with: docker-compose up -d or docker-compose start i got the error message: ERR_EMPTY_RESPONSE.
I tried:
Removing the containers, services and volumes
Killing the netstat port
Currently I have no idea why it isn't working anymore. I am working on macOS
This is my current docker-compose.yml
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
volumes:
- ./plugins/my-plugin:/var/www/html/wp-content/plugins/my-plugin
- ./themes/my-theme:/var/www/html/wp-content/themes/my-theme
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpres
volumes:
db_data: {}
The status of containers after running it:
Follow these steps
docker-compose down - twice
Edit the yml file and replace all instances of db_data with db_datax
Run docker-compose up -d
Alternately,
docker-compose down - twice {removes the network as well}
docker system prune --volumes
docker-compose up -d
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)