The network ports of the container need to be configurable
Closed this issue · 0 comments
KamranAzeem commented
There are times when this container image may be used to troubleshoot another container by making it part of the same IP namespace (i.e. two or more containers sharing the same IP address). In case any of the container runs a web server, such as regular nginx container (not alpine version), then multitool cannot join the same container.
Example:
[kamran@kworkhorse network-multitool]$ docker run --name nginx -d nginx
6e8b6ed8bfa67f6b7119804f2217e46d8c5ebecd0dd4b6ec6bc5099f2ebe60c4
[kamran@kworkhorse network-multitool]$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6e8b6ed8bfa6 nginx "nginx -g 'daemon of…" 2 seconds ago Up 1 second 80/tcp nginx
[kamran@kworkhorse network-multitool]$ docker exec -it nginx sh
# netstat -ntlp
sh: 1: netstat: not found
# ifconfig
sh: 2: ifconfig: not found
# curl localhost
sh: 3: curl: not found
# exit
[kamran@kworkhorse network-multitool]$
[kamran@kworkhorse network-multitool]$ docker run --name multitool --net container:nginx -d praqma/network-multitool
17afa2eda1c43d6787975bcfdb4d3ace9044a72c0d38a7d74d65827779a7a774
[kamran@kworkhorse network-multitool]$
[kamran@kworkhorse network-multitool]$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6e8b6ed8bfa6 nginx "nginx -g 'daemon of…" 3 minutes ago Up 3 minutes 80/tcp nginx
[kamran@kworkhorse network-multitool]$
[kamran@kworkhorse network-multitool]$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
17afa2eda1c4 praqma/network-multitool "/docker-entrypoint.…" 30 seconds ago Exited (1) 26 seconds ago multitool
6e8b6ed8bfa6 nginx "nginx -g 'daemon of…" 3 minutes ago Up 3 minutes 80/tcp nginx
[kamran@kworkhorse network-multitool]$
[kamran@kworkhorse network-multitool]$ docker logs multitool
2019/07/29 11:08:08 [emerg] 13#13: bind() to 0.0.0.0:80 failed (98: Address in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address in use)
2019/07/29 11:08:08 [emerg] 13#13: bind() to 0.0.0.0:80 failed (98: Address in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address in use)
2019/07/29 11:08:08 [emerg] 13#13: bind() to 0.0.0.0:80 failed (98: Address in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address in use)
2019/07/29 11:08:08 [emerg] 13#13: bind() to 0.0.0.0:80 failed (98: Address in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address in use)
2019/07/29 11:08:08 [emerg] 13#13: bind() to 0.0.0.0:80 failed (98: Address in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address in use)
2019/07/29 11:08:08 [emerg] 13#13: still could not bind()
nginx: [emerg] still could not bind()
[kamran@kworkhorse network-multitool]$
This means the port of the container needs to be configurable at run time , using some "port modifier directive"/"environment variables". It should serve on default ports 80 and 443 if port modifier directives are not present.