Hi all,
I have a question about the ‘port forwarding’ of docker. I can not seem to be able to get it to work. I must be doing something wrong. I hope someone can set me back on the right path!
I built a wordpress environment that works fine when all is set on port 80 (host and container), but as soon as I get the host to listen on port 8080, it fails.
My settings:
docker-compose yaml file
[...]
wp:
build: httphp
name: wp
hostname: wp
ports:
- "0.0.0.0:8080:80"
volumes_from:
- wpdata
links:
- db
[...]
The Docker file of the wordpress container
FROM php:5.6-apache
[...]
COPY webapp.conf /etc/apache2/sites-available/
COPY security.conf /etc/apache2/conf-available/security.conf
COPY entrypoint.sh /
CMD ["/entrypoint.sh"]
The webapp.conf file
<VirtualHost *:80>
ServerName 192.168.1.4
[...]
the entrypoint file
[...]
wp core install --allow-root --path=/var/www/html --url=http://192.168.1.4/ --title="${WP_TITLE}" --admin_user=${WP_USER} --admin_password="${WP_PASSWORD}" --admin_email="${WP_EMAIL}"
[...]
where ‘192.168.1.4’ is the IP of the host.
My result
(1) From my computer, I browse to 192.168.1.4:8080 and get a “Can’t connect to the server” in the browser but a response from the container
wp_1 | 192.168.1.10 - - [08/Aug/2015:19:55:54 +0000] “GET / HTTP/1.1” 301 329 “-” “Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/600.7.12 (KHTML, like Gecko) Version/8.0.7 Safari/600.7.12”
I’m guessing this means that the container wants to display the page and does so on port 80 and the port forwarding does not relay the info.
$ curl -LI http://192.168.1.4:8080/
HTTP/1.1 301 Moved Permanently
Date: Sat, 08 Aug 2015 20:00:46 GMT
Server: Apache/2.4.10 (Debian) PHP/5.6.11
X-Powered-By: PHP/5.6.11
X-Pingback: http://192.168.1.4/xmlrpc.php
Location: http://192.168.1.4/
Content-Type: text/html; charset=UTF-8
curl: (7) Failed to connect to 192.168.1.4 port 80: Connection refused
(2) From my computer, I browse to 192.168.1.4:80 nd get absolutely nothing. Figures.
$ curl -LI http://192.168.1.4/
curl: (7) Failed to connect to 192.168.1.4 port 80: Connection refused
(3) I get the exact same result on the host.
(4) From the host I query the IP of the container directly on port 80 and it of course works.
$ curl -LI http://172.17.0.6:80/
HTTP/1.1 200 OK
Date: Sat, 08 Aug 2015 20:05:23 GMT
Server: Apache/2.4.10 (Debian) PHP/5.6.11
X-Powered-By: PHP/5.6.11
X-Pingback: http://192.168.1.4/xmlrpc.php
Content-Type: text/html; charset=UTF-8
Please help. What am I doing wrong. I’m so close but no cigar!