Issue
I'm setting up a docker container on a linux server and I'm trying to set up a VirtualHost so that when I visit the domain I own it will show that website.
I have a DNS record on my domain to use the IP address of my linux server, and I installed apache on there to test and it worked properly.
If I start my container with
docker run -dit --name web-app -p 8080:80 web-image
I can go to mydomain.com:8080 and see my website, but it doesn't work if I just navigate to mydomain.com.
My VirtualHost stanza in httpd.conf
is
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName mydomain.com
ServerAlias mydomain.com
DocumentRoot /usr/local/apache2/htdocs
</VirtualHost>
The only thing I can think is that I need to update my domain DNS definition to accept the Docker Container IP address?
Is there something I'm missing?
Solution
It's quite obvious, that the website is available on port 8080
, but not port 80
, since you define -p 8080:80
. You need to expose port 80
instead.
docker run -dit --name web-app -p 80:80 web-image
Answered By - Alex Karshin Answer Checked By - David Goodson (WPSolving Volunteer)