3

I am new to the fabulous world of docker and star twith asking a quite noobish question I think. But first, a little information about myself:

I am working with exist-db and plan to move it to docker. So set it up on the server, I thought and followed this instructions. I am not importing my app, yet, as I want to familiarize with how it works, before I move towards “the cloud”.

I am running docker on a server, which I access using Putty. I have set it up properly, even my existdb container works:

curl localhost:8080

gives me the html-output I am expecting from existDB. However, when I attempt to [server-IP]:8080 in firefox, I cannot access it.

I know I haven’t configured anything else yet, besides when I started the container, but the following.

docker run -it -d -p 8080:8080 -p 8443:8443 --name exist existdb/existdb:latest

Shouldn't this bind my container[8080] to my host[8080] (or 8443 for that matter), so that I should in theory be able to [Host-ip]:8080 and see the exist Interface?

I do not want to use host-mode, as I'll probably have several apps up& running in the future, so that I think it better to separate the interfaces.

  • It is advisable to use a reverse proxy, traefik for example, in a setup where you run multiple web applications on one host. – funky-future Jun 21 '20 at 10:41

1 Answers1

-1

Following this answer here and I quote

By default, Docker exposes container ports to the IP address 0.0.0.0 (this matches any IP on the system). If you prefer, you can tell Docker which IP to bind on. To bind on IP address 10.0.0.3, host port 80, and container port 8080:

docker run -p 10.0.0.3:80:8080 <your image>

following the comments i have tried to regenrate the setuation and as you can see

CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS                   PORTS                                            NAMES
9eebf8c6f3b2        existdb/existdb:latest   "java org.exist.star…"   2 minutes ago       Up 2 minutes (healthy)   0.0.0.0:8080->8080/tcp, 0.0.0.0:8443->8443/tcp   exist

so you need to run the command like the following docker run -it -d -p 0.0.0.0:8080:8080 -p 0.0.0.0:8443:8443 --name exist existdb/existdb:lates

Kerolos William
  • 435
  • 2
  • 12
  • And how specifically does that help me? I want to be able to access the container via the browser, while the container sits at a location far away? I mean no disrespect, probably I am missing a step (or two or three). So I need to run it with a specific IP and then add `-p 9080:8080 -p 9443:8443` at the end? –  Dec 12 '19 at 15:29
  • as mentioned in the answer (any IP) means that the port will be exposed to the public ip of your server which you access from the browser so you can just do this to make sure `docker run -p 0.0.0.0:8080:8080 ` – Kerolos William Dec 12 '19 at 15:34
  • so you are saying that after doing what I did my server-ip:8080 should have worked? as I perceive, flags aside, `docker run -it -d -p 8080:8080 -p 8443:8443 --name exist existdb/existdb:latest` does exactly what you told told? it maps host-8080 to container-8080 (and 8443) so that server-ip:8080 should result in me getting the container visible? I could not get any port combination to work ... I'll turn back here when it does not work with a different server –  Dec 12 '19 at 15:40
  • what i am saying that it should by default bind the port to all network interfaces (including your public one that's mean you can use the public ip or as you say server-ip:port) if you wanna make sure you can use `docker run -it -d -p 0.0.0.0:8080:8080 -p 0.0.0.0:8443:8443 --name exist existdb/existdb:latest` – Kerolos William Dec 12 '19 at 15:48
  • also to help you debug from inside the server itself check the output of the following command `ss -plant | grep 8080` after you run the docker from inside the server itself not from inside the docker and see which IP is bind to the port this is to check http://man7.org/linux/man-pages/man8/ss.8.html – Kerolos William Dec 12 '19 at 15:51
  • also note you are using -it in the docker run command and in the same time you are using -d i recommend checking the documentation for each option and what it do https://docs.docker.com/engine/reference/run/ – Kerolos William Dec 12 '19 at 15:52
  • to the last comment: I copied that from exist-DB docker-hub! regarding those before, https://pastebin.com/MCHE6sZ2. and still, I cannot access host-ip:8080 in my browser ... I am like ten seconds short to set up my whole server new ... what the hell am I missing -.- –  Dec 12 '19 at 15:57
  • kindly check the updated answer if you are in AWS EC2 you need to check also the security groups to allow the port to be public accessible also check you firewall rules – Kerolos William Dec 12 '19 at 16:07
  • I am using a ionos VPS. Sorry, it took so long. my container is starting for two minutes now :-o still, I cannot use the public-ip:8080. I haven't even set up any firewalls rules just yet ...the only thing currently running is f**n docker with ONE exist-container –  Dec 12 '19 at 16:22
  • From your local network whats the output of the following command. Telnet server-ip 8080 – Kerolos William Dec 12 '19 at 16:29
  • windows 10 , have to reactivate telnet ... Could not establish connection to host, on Port 8080. connection error. (I am translating this on the fly from german ...) The german reads like this: Verbindungsaufbau zu Server-IP ...Es konnte keine Verbindung mit dem Host hergestellt werden, auf Port 8080: Verbindungsfehler –  Dec 12 '19 at 16:36
  • I can't understand german. What's the error that appears from the browser. And output of docker ps from the server – Kerolos William Dec 12 '19 at 16:45
  • Browser error is network time-out (also an on the fly translation, but I'm pretty sure that's the most accurate translation) –  Dec 12 '19 at 16:48
  • Usually time-out errors come from firewalls make sure you didn't don't have blocking firewalls locally or on the server or from the datacenter itself – Kerolos William Dec 12 '19 at 16:51
  • for now, I only have one allowing every IP on Port 8080. Before that I had none active ... I am really confused now ... –  Dec 12 '19 at 17:02
  • I have absolutely no idea as to WHY it now works ... :-D but after countless times of cursing and sipping coffee and replacing it with warm coffee again, it works ... :-D Now I need to find a way to add existDB's apps that it comes with, when installed locally –  Dec 12 '19 at 17:25
  • Glad it worked you can now go on and check the dockerfiles and how to build your own docker image – Kerolos William Dec 12 '19 at 17:57
  • @kev1807 Hello, after reading this post, maybe you have now a broad sense as to why it works, so that you can clarify it please? Or maybe point to some resource? – Mauricio Maroto Aug 18 '20 at 15:21