0

I am trying to deploy my application on docker environment. When i deploy that application using 'host' networking, i am able to access that application outside.

docker run -d --network="host" --env-file  communication.txt -p 8001:8080 img-name:latest

with this application is running on vm-ip as --

2020-04-09 10:39:34,810 [main] INFO  io.micronaut.runtime.Micronaut - Startup completed in 2405ms. Server Running: http://ip-192-168-X-XXX:8001

This is accessible with http://192-168-X-XXX:8001

But when i use networking type bridge it's not working. When we don't specify the network type by default it will take bridge network.

docker run -d --env-file  communication.txt -p 8001:8080 img-name:latest

Here it is taking container name as:

2020-04-09 11:25:27,513 [main] INFO  io.micronaut.runtime.Micronaut - Startup completed in 2361ms. Server Running: http://1c2b3ba67ace:8001

I am not able to access this application outside.

What can be the reason am not able to predict.

Any help will be appreciated. Thanks in advance

Jan Kislinger
  • 1,441
  • 14
  • 26
  • but what hostname is `1c2b3ba67ace`? I once had a similar problem, and i was only able to access it through IPv6, not IPv4 for some odd reason.. – Frank Nielsen Apr 09 '20 at 12:01
  • The last log message looks like the process inside the container is listening on port 8001, not 8080. That needs to match the second port number in the `docker run -p` option. (This option is completely ignored with `--net host`.) – David Maze Apr 09 '20 at 12:09
  • Does this answer your question? [What does --net=host option in Docker command really do?](https://stackoverflow.com/questions/43316376/what-does-net-host-option-in-docker-command-really-do) – Arnaud Claudel Apr 09 '20 at 12:14
  • But in `bridge` mode, you listening directly on the host network and therefor not using the port mapping or? – Frank Nielsen Apr 09 '20 at 12:15

1 Answers1

0

Thanks @David Maze

When i specified same port in docker run -p, it worked.

docker run -d --env-file  communication.txt -p 8001:8001 img-name:latest

This worked for me. Thank You so much