Docker Community Forums

Share and learn in the Docker community.

Turn my pc into a web server [non solved]


(Dockergi) #1

I have created an http server that communicates with my host. I would like my docker container to communicate with the whole world.
I want to turn my pc into a web server.

I need another starting image, can I edit the following codes or should I be a systems engineer?

Thanks as always!

Dockerfile:
FROM httpd:2.4
LABEL Author="Nome Cognome"
EXPOSE 80
COPY ./htdocs/ /usr/local/apache2/htdocs/
CLI:
docker build -t apache_server:v1 .
docker run -d --name apache_server_container -p 8088:80 apache_server:v1

OS / build version: Windows 8.1
App version: 18.09.0

I would like to learn how to do this on my pc so then I can do the same thing on any vps.


#2

This is a very open ended question.

The code you have here does indeed make your PC into a webserver, (assuming you have a folder called htdocs with the content you want to serve in the same folder as this Dockerfile)

But what are you hoping to achieve and what problems are you having?


(Dockergi) #3

I would like to read the file ./htdocs/index.html on my PC from another computer connected to the internet by typing an URL like this in the browser:
http://192.xxx.yyy.zzz:8088/index.html


#4

Okay, well, yeah, you’re going to be able to do that, but there’s a problem docker can’t fix for you: addresses starting with 192.168 will not be reachable from the internet, only your own LAN. And that’s a problem that can only be addressed through your default gateway hardware. If you’re your own network admin, you need to look at your router’s configuration for port forwarding, but, again, there’s no docker-based solution that can fix that for you.


(Dockergi) #5

Sorry, I was wrong to write.
Any IP address is fine.
The url I have in mind is this:
http://xxx.yyy.zzz.vvv:mmmm/index.html
Is there already something ready on docker?


(Simog) #6

You don’t need to do anything to your Docker settings. You need to configure a public IP to your computer, that’s a networking issue thats not related to Docker. As said the 192.168 starting IP is a b-class address range that is not visible to the outside world. So as long as your ‘server’ PC has that sort of an address, you’re blocked from the wan. You’ll need to address this in your router/modem and possibly subscribe to DynDNS if your public IP is not static (most consumer accounts are not).

If your host PC is a Windows workstation, you’ll probably get hacked/infected in no time if you expose it directly to the live net. The live web is steaming with attack scripts, worms etc.

Note also that many ISPs do not allow running private servers using a consumer subscription.


(Dockergi) #7

Thanks for your answers.
In a vps instead changes something?
If I use my dockerfile on any VPS is my docker code enough?
On a VPS are other software necessary to make the htdocs content accessible to the Internet in complete safety?