Reputation: 81
I am trying to set up a local Wordpress environment using Docker Compose for the first time. I am currently able to access my Wordpress instance on localhost:8080
and have the files mapped locally.
I purchased a theme, added it to wp-content/themes
, and was then prompted to install some required plugins for it. When I click Install
, this is the error I receive:
Download failed. cURL error 7: Failed to connect to localhost port 8080: Connection refused
Here is my configuration file:
version: "2"
services:
my-wpdb:
image: mariadb
ports:
- "8081:3306"
environment:
MYSQL_ROOT_PASSWORD: password
my-wp:
image: wordpress:latest
volumes:
- ./:/var/www/html
ports:
- "8080:80"
links:
- my-wpdb:mysql
environment:
WORDPRESS_DB_PASSWORD: password
Probably a simple fix, but I can't seem to figure it out. Thanks!
Upvotes: 8
Views: 6835
Reputation: 71
I agree with PaulH's solution. Execute the following commands inside the running WordPress Linux Docker container then restart the container.
echo -e "\nListen 8080\n" >> /etc/apache2/ports.conf
echo -e "\n<VirtualHost *:*>\n</VirtualHost>\n" >> /etc/apache2/sites-available/000-default.conf
cat /etc/apache2/ports.conf && cat /etc/apache2/sites-available/000-default.conf
Upvotes: 2
Reputation: 51
Following on from papey's answer. curl is trying to connect on the outside port (8080 in your case) whilst inside the container (80).
After much Googling and the only solution people gave was changing the inside and outside ports to 80:80. This is not feasible if you are running another service on port 80.
My solution was to modify the Apache2 conf inside the container so that Apache will respond inside on the outside port. There may be better ways but this is working.
/etc/apache2/ports.conf
Listen 80
Listen 8080
/etc/apache2/sites-available/000-default.conf
<VirtualHost *:*>
Upvotes: 5
Reputation: 4134
According to you docker-compose :
- "8080:80"
8080 is OUTSIDE the container
80 is INSIDE the container
Upvotes: 1