简体   繁体   English

打印容器 id 的 Docker 图像

[英]Docker image that prints container id

Im loking for a docker image that can print the container ID in a web browser, Something like the httpd that prints ("Is Working") but printint the container id.我正在寻找可以在 web 浏览器中打印容器 ID 的 docker 图像,类似于打印的 httpd(“正在工作”)但打印容器 ID。

I want to try if a load balancer that i just set up is working.我想试试我刚刚设置的负载均衡器是否正常工作。

You can you this image .你可以你这个形象

docker run -p 8080:8080 -p 8443:8443 --rm -t mendhak/http-https-echo:18

to start the server and then启动服务器,然后

curl http://localhost/hello-world

to get headers (including the hostname, which also happens to be this container's ID) back.获取标头(包括主机名,也恰好是此容器的 ID)。

UPD:升级版:

Another way to get only the hostname is to run something like this:仅获取主机名的另一种方法是运行如下内容:

PORT=8091
docker run --rm -it -e PORT=$PORT -p $PORT:$PORT busybox sh -c \
'while true; do echo -e "HTTP/1.1 200 OK\n\n `cat /etc/hostname`" | nc -l -p $PORT; done'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM