简体   繁体   English

如何使用 Docker 在 TCP 上将二进制文件作为服务托管?

[英]How do I host a binary as a service over TCP using Docker?

I have learned how to use Docker containers, and I'd like to set up a container which contains a binary so that:我已经学会了如何使用 Docker 容器,我想设置一个包含二进制文件的容器,以便:

  • If I ssh to the Docker container, I am prompted as though I had just executed the binary locally如果我 ssh 到 Docker 容器,我被提示好像我刚刚在本地执行了二进制文件
  • If I hit a condition that causes the binary to exit, it will restart and prompt me from the beginning again如果我遇到导致二进制文件退出的条件,它将重新启动并再次从头开始提示我

I get how to expose ports in my containers and I get the gist of Docker networking, but I don't get how to proxy my binary over TCP as described above, the way I often see CTF challenges set up.我了解了如何在我的容器中公开端口,并且了解了 Docker 网络的要点,但是我不知道如何如上所述通过 TCP 代理我的二进制文件,我经常看到 CTF 挑战设置的方式。 Any specifics are much appreciated.任何细节都非常感谢。

Edit: I'll also add that I know how to copy the binary into the container during the image creation.编辑:我还要补充一点,我知道如何在创建映像期间将二进制文件复制到容器中。 I'm just trying to figure out the service part.我只是想弄清楚服务部分。

I was looking for netcat and its -e option, to redirect stdin and stdout to a port.我正在寻找 netcat 及其 -e 选项,以将标准输入和标准输出重定向到端口。 Putting a while loop around the netcat call gave me what I'm looking for.在 netcat 调用周围放置一个 while 循环给了我想要的东西。

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

相关问题 如何将在boot2docker中运行的Docker容器连接到在另一台主机上运行的网络服务? - How do I connect a Docker container running in boot2docker to a network service running on another host? 使用“ docker build”时如何获取主机地址? - How do I get the address of the host when using 'docker build'? 如何在使用 Windows 主机时挂载 Docker 卷? - How do I mount a Docker volume while using a Windows host? 如何使用docker service create设置环境变量? - How do I set an environment variable using docker service create? 如何使用Docker容器内的主机IP地址使其自身可访问服务? - How can I make a service accessible to itself using host IP address inside a Docker container? 如何在Docker中设置服务主机? - How to set host of service in Docker? 如何从docker容器向主机发送tcp / ip请求? - How do you send tcp/ip requests from a docker container to the host? 为 mySQL 和 redmine 使用 docker 图像,如何解决“未知 MySQL 服务器主机”? - using docker images for mySQL and redmine, how do I resolve "Unknown MySQL server host"? 如何使用 docker-compose 将 MongoDB 数据卷备份到主机? - How do I backup a MongoDB data volume to host using docker-compose? 如何使用Windows的Docker桌面从主机连接到Cassandra - How do I Connect from Host to Cassandra using Docker Desktop for Windows
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM