Home > Enterprise >  Communicate with GET request between 2 applications - only one of them run as a docker container
Communicate with GET request between 2 applications - only one of them run as a docker container

Time:12-19

I have created an image of my application and run a container on one machine. my inner container port is: 8081.

I see that the container is running.

I would like to talk with that container from another machine from an application that doesnt run as a docker container, with a GET request, all the machines in the same VLAN.

How do I communicate with that docker container from another machine? with which ip and port ?

in the first trial - I run the container with the exposed port as the inner port :

    sudo docker run -d -p 8081:8081 myimage:2.0

in my second trial I run the container like this:

    sudo docker run -d -p 80:8081 myimage:2.0

CodePudding user response:

Exposing the port with the -p <outside>:<inside> flag will pass through the all traffic on the outside port of your machine running the container to the inside port in your container. So you can just communicate with the container through either port 80 or port 8081 depending on what command you start your container with. The ip will be the ip of the machine running the container.

CodePudding user response:

finde your container ip with this command:

docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <container_name>

and proxy pass with nginx service and apache etc.

  • Related