I'm running a local Wordpress instance in a docker container build using wordpress latest image. According to Wordpress Site Health tool the REST API is not working. I get this error:
Error: cURL error 7: Failed to connect to localhost port 8000: Connection refused (http_request_failed)
My docker-compose looks like this
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
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
db_data: {}
I tried also Bitnami image, but the effect is the same.
How can I get this working?
A friend solved this for me.
Stop the containers.
Change "8000:80" in docker-compose.yml to "80:80".
Remove db volume - this will remove all db data
docker volume ls find volume name
docker volume rm <name> in this case it's wordpress_db_data
Start the containers and go to http://localhost/
You could probably also just update the settings in the Wordpress dashboard but installing it again seemed more convenient.
Now Wordpress Site Health should show no errors.
Related
I downloaded a github folder with a wordpress site, after the unzip the weight of it is about 1,8 gb.
Inside the master folder I've 9 folders, two of them named:
1: wp-content
2: wp-includes
I already created the docker-compose.yml file and the code inside it is this:
version: '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:5.1.1-php7.3-apache
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
working_dir: /var/www/html
volumes:
- ./wp-content:/var/www/html/wp-content
- ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
volumes:
db_data:
The lines up above are necessary only for install wordpress.
Now my question is, what could I do to install and launch the complete site that i downloaded ?
The entire process must be done with docker, install and launch the site.
Thank you for everything :)
Ensure you have the volume mount points which contains the existing app source code and the db files and the script to do db update.
wordpress section in docker-compose
volumes:
- ./codeblog.dotsandbrackets.com:/var/www/html
mysql section in docker-compose
volumes:
- ./codeblog.dotsandbrackets.com.20170808-024302.sql.gz:/docker-entrypoint-initdb.d/backup.sql.gz
- ./migrate.sql:/docker-entrypoint-initdb.d/migrate.sql
This example uses nginx webserver
Ref : https://codeblog.dotsandbrackets.com/migrate-wordpress-docker/
I'm trying to set up wordpress with Docker Desktop on Mac. I followed this guide: https://docs.docker.com/compose/wordpress/
When I run docker-compose up -d, it tells me db & wordpress are up-to-date. But, visiting localhost:8000 results in this error: This page isn’t working localhost didn’t send any data. ERR_EMPTY_RESPONSE . I also tried 127.0.0.1:8000 - same result.
Again, curl localhost:8000 just gives me: (52) Empty reply from server
I'm also using Local by Flywheel on my machine. Could that cause a conflict perhaps?
My 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
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
db_data: {}
I solved it, but I don't know why it worked. I followed what someone had done here: https://forums.docker.com/t/wordpress-example-in-docker-compose-fails/30438/3
Basically I changed volume to db_data:/var/lib/mysql2, and also changed wordpress image to wordpress:php7.1. After running docker-compose up it worked.
It took me a while but I finally setup Wordpress in Docker for windows, the install went fine and I have a working wordpress site at http://localhost:8080 I can't for the life of me figure out how to access the wordpress files, such as everything in wp-content. I know they live in the container, but how do I go about developing with my code editor, I need to edit stuff in the themes folder.
I have seen in a tutorial that said to map my directories like this in my docker-compose.yml file
working_dir: /var/www/html
volumes:
- wordpress/wp-content/:/var/www/html/wp-content
I don't see how this helps be get to my files, I am running windows so I need to access them in my C drive ideally in C/Users/Andersk/Sites/Wordpress... I will include my current docker-compose.yml file below. Hopefully some one can help. Thanks
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
ports:
- "8080:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
volumes:
db_data: {}
Click on the Docker icon in your system tray and select Settings, then click on Shared Drives. Make sure your C: drive is shared.
Now you should be able to add this to wordpress service section in your docker-compose.yml:
volumes:
- C:/Users/Andersk/Sites/Wordpress:/var/www/html/wp-content
I am trying to host multiple sites on a single Digital Ocean VPS. I am using docker to achieve this. Each Wordpress site has its own database.
Using the docker-compose file of any of the two sites works fine and the site goes live. Adding a second does not work. (Navigating to the domain gives an nginx error of 'service temporarily unavailable')
I tried launching a static website from a container based on an apache image, and it does indeed work. So the nginx reverse proxy does successfully route traffic.
I am guessing that there is something more that I need to change between the two docker-compose files. Every tutorial or sample I've found stops after creating the first, and never actually shows a second Wordpress site being created.
Wordpress site 1:
docker-compose.yml
version: "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
container_name: site1_db
wordpress:
depends_on:
- db
image: wordpress:latest
expose:
- 80
restart: always
environment:
VIRTUAL_HOST: www.site1.com
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
container_name: site1_wp
volumes:
db_data:
networks:
default:
external:
name: nginx-proxy
Wordpress site 2:
docker-compose.yml
version: "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
container_name: site2_db
wordpress:
depends_on:
- db
image: wordpress:latest
expose:
- 80
restart: always
environment:
VIRTUAL_HOST: www.site2.com
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
container_name: site2_wp
volumes:
db_data:
networks:
default:
external:
name: nginx-proxy
A network named nginx-proxy was created beforehand to link all the containers. I left out the details about the nginx instance as it uses the well known jwilder image and like I said, it does seem to work just fine.
I finally found the answer. It is two-fold:
The WORDPRESS_DB_HOST environmental variable should not be the service, but rather the container that it is referencing
Thus change:
WORDPRESS_DB_HOST: db:3306
to:
WORDPRESS_DB_HOST: site1_db:3306
The same obviously goes for site2
The fix above still does not result in a working setup. When changing the database container to build from mariadb instead of mysql, it starts working! I have no idea in the slightest why this is true. Especially since the mysql instances can work on their own, but when running simultaneously, only mariadb works
I run a WP in docker container with mysql with docker-compose. I put a volume on host machine and everything goes well. During my development I install some themes.
When I am going to deploy my configuration to docker swarm:
1. I create from my wp container an image and commit it to repository
2. I share a volume from the host machine to wp service with mysql db
However when I run it in swarm mode - my installed themes are not there.
version: '3'
services:
db:
image: localhost:5000/db2
volumes:
- ./realsitermark_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: localhost:5000/rw
volumes:
- ./engage/engage/:/var/www/html/wp-content/themes/engage
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
You're mounting your theme engage using:
- ./engage/engage/:/var/www/html/wp-content/themes/engage.
To use uploads, mount the entire wp-content directory.