Turn my pc into a web server [solved]

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.

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?

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

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.

1 Like

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?

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.

1 Like

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?

Your Docker exposes the port 80 to the world. So if your computer can be seen by the world, the Docker also works. You should configure your router / firewall to give you a public IP address and allow port 80 through the firewall. Many consumer routers have a special ethernet port for ‘DMZ’ which allows you to plug your computer in a zone that can be opened to the public.

First you need to figure out if your internet connecion allows you a direct access to a public ip. Then configure it to your ‘server’ and allow port 80 in/out tcp in the firewall. After that you can access your docker hosted apache using your computers public IP.

Most likely it would be easyer for you to get a Jelastic account from some hosting provider, costs only a couple of bucks a month at minimum use.

no sooner said than done!
https://forums.docker.com/t/create-a-web-server-with-ubuntu-18-04-and-an-amazon-aws-not-solved/65051
thanks