How do i get a container to communicate on the docker host network?



  • Man page for docker run: http://bit.ly/2h77MqO

    The use of the host network on docker can do this. Run a docker container exposing a port and listen to it using netcat.

    $ docker run -d --expose 5002 --network host alpine /bin/sh -c "echo Hello docker world | nc -lp 5002"
    

    Verify that it is listening in on the that host port.

    $ curl http://localhost:5002
    Hello docker world
    


© Lightnetics 2024