如何将 Docker 终端暴露到互联网上?
我正在为不同语言创建在线IDE。因此,我对此的方法是将用户运行代码后,从我的Django应用程序中旋转一个docker容器,但是问题是我如何将Docker容器的终端公开到Internet上并通过浏览器访问?我计划将XterM.JS用于终端的前端,但无法连接到它。
任何形式的见识都是可观的。
I am creating an online IDE for different languages. So my approach to the same is to spin up a docker container from my DJango app once a user runs his code, but the problem is how do I expose the terminal of the docker container to the internet and make it accessible via the browser? I am planning to use xterm.js for the frontend of the terminal but am unable to connect to it.
Any form of insight is appreciable.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用nginx的反向曲线来指向您的localip:< container_port>,然后用域名修改。
如下所示:
添加一些链接来帮助您。
在此处输入链接说明
您也可以使用'>您也可以使用'> nginx代理经理'
You can you an reverse-proxy with NGINX to point to your localIP:<container_port>, and then modify with your domain name.
As this exemple below:
Adding some links to help you.
enter link description here
Also you can use 'Nginx Proxy Manager'
简短答案:
您的应用程序使用端口访问它(例如,您使用127.0.0.1:8080或192.168.1.100:3000)。
127.0.0.1是指您现在使用的计算机,192.168.1.100是192.168.1.0网络中的计算机。 (您的LAN)
您必须(在路由器上)从Internet访问应用程序。
对于示例,如果您的公共IP地址为123.245.123.245,则需要使用外部端口(例如:80),并将其映射到您的内部地址和端口(例如:192.168.1.100:3000)
URL 123.245.123.245: 80将在192.168.1.100:3000重定向到网站。
在短期内,这是最简单的解决方案。
从长远来看,您应该尝试使用反向代理。
这是一个程序(取决于域),将其重定向到网络内的站点并在请求中添加加密(如果可能的话)。
检查此链接: doc
Short answer:
Your application uses a port to access it (for example, you use 127.0.0.1:8080 or 192.168.1.100:3000).
127.0.0.1 means the computer you are using right now, 192.168.1.100 is a computer inside the 192.168.1.0 network. (Your LAN)
You must create (on your router) access from the internet to your application.
For exemple, if your public IP address is 123.245.123.245, you need to use an external port (ex: 80), and map it to your internal address and port (ex: 192.168.1.100:3000)
the URL 123.245.123.245:80 will redirect to the website on 192.168.1.100:3000.
On the short term, this is the easiest solution.
For the long term, you should try using a Reverse Proxy.
It's a program that will (depending on the domain) redirect to sites inside your network and adding encryption in the requests (if possible).
Check this link : doc