3 ms·
You don't have to use -p with docker's default settings. $ docker run --rm --name listen busybox sh -c 'echo hi | nc -l -p 8000' # in another termina
by TheDong 2y ago
You don't have to use -p with docker's default settings.
$ docker run --rm --name listen busybox sh -c 'echo hi | nc -l -p 8000'
# in another terminal
$ docker inspect listen -f '{{ .NetworkSettings.IPAddress }}'
172.17.0.3
$ nc 172.17.0.3 8000 < /dev/null
hi
Works just fine for accessing it on your local machine. The -p flag is meant to "publish" a port so it's available remotely, from outside of your machine (i.e. to serve nginx to the public internet on a webserver with '-p 80:80' or whatever).