How to send HTTP requests to my server running in a docker container? How to send HTTP requests to my server running in a docker container? docker docker

How to send HTTP requests to my server running in a docker container?


you are doing EXPOSE 3972 which exposes the port to other linked containers but NOT to the host machine

To expose the port to the host machine you do ...

docker run -p 3972:3972 ....... etc

you can also do ...

docker run -P

which exposes all ports exposed by EXPOSE to the host (this is not the default - you must use the -P flag here)


Are you using Docker Toolbox???

In my case, the normal docker installation didnt work on my Windows 10 so I had to install Docker toolbox; docker toolbox adds a virtual machine where the docker runs all their containers.

For example, to access my dockerized apps I have to use: http://192.168.99.100:8080/app.

Here, 192.168.99.100 is the virtual machine ip.

Hope it helps you!!!!


Use the "action="http://192.168.99.100:8080/rest/data/ingest" in your html to refer to your Docker Container's Rest Path. See the bottom HTML Code, line 4.

http://192.168.99.100:8080/rest/data/ingest Breakdown:

1) 192.168.99.100:8080= Docker's IP Address & Port #.

2) /rest/ = In your web.xml file

3) data/= @Path("/data")

4) /ingest= @Path("/ingest")

HTML CODE:

<html>    <body>        <h1>Data Ingest: Web Uploader</h1>             <form action="http://192.168.99.100:8080/rest/data/ingest" method="post" enctype="multipart/form-data">           <p>Select files: <input type="file" name="file" size="10000000" multiple/> </p>            <input type="submit" value="Upload Files"/>        </form>    </body></html>

JAVA CODE:

@Path("/data")public class YourClass {@POST@Path("/ingest")public Response yourMethod (...){}