简体   繁体   English

无法访问通过Docker和Google Cloud部署的应用

[英]Can't access app deployed with docker and google cloud

I currently have a Linux Debian VM set up through Google Cloud Platform. 我目前通过Google Cloud Platform设置了Linux Debian VM。 I have docker installed and would like to start running application containers within it. 我已经安装了docker,并想开始在其中运行应用程序容器。

I'm following the documentation under Docker's website Found Here under "Running a web application in Docker" I download the image and run it with no issue. 我正在遵循Docker网站上的文档,在“在Docker中运行Web应用程序”下的“ 找到此处 ”中,我下载了映像并运行了它。 I then run $sudo docker ps and get the port which is 0.0.0.0:32768->5000/tcp 然后我运行$sudo docker ps并获取端口为0.0.0.0:32768->5000/tcp

I then try to browse to the website at http://"MyExternalVMIP":32768 but the applications doesn't come up. 然后,我尝试浏览至http://“ MyExternalVMIP”:32768的网站,但应用程序没有显示。 Am I missing something? 我想念什么吗?

First, test to see if your service works at all. 首先,测试一下您的服务是否可以正常工作。 To do this, from the VM itself, run: 为此,请从VM本身运行:

wget http://localhost:32768

or 要么

curl http://localhost:32768

If that works, that means the service is operating properly, so let's move further with the debugging. 如果这可行,则意味着服务运行正常,因此让我们进一步进行调试。

There may be two firewalls that are blocking external access to your docker process: 可能有两个防火墙阻止了对docker进程的外部访问:

  1. the VM's OS firewall VM的OS防火墙
  2. Google Compute Engine firewall Google Compute Engine防火墙

You can see if you're affected by the first issue by accessing the URL from the VM itself and from another VM on the same GCE network (use the VM name in the URL, not the external IP): 您可以通过从VM本身和同一GCE网络上的另一个VM访问URL来查看是否受到第一个问题的影响(使用URL中的VM名称,而不是外部IP):

wget http://[vm-name]:32768

To fix the first issue, you would have to either open up the single port (recommended): 要解决第一个问题,您将必须打开单个端口 (推荐):

iptables -I INPUT -p tcp -s 0.0.0.0/0 --dport 32768 -j ACCEPT

or disable firewall entirely, eg, by stopping iptables (not recommended). 或完全禁用防火墙,例如,通过停止iptables(不推荐)。

If, after fixing this, you can access the URL from another host on the same GCE network, but still can't access it from outside of Google Compute Engine, you're affected by the second issue. 解决此问题后,如果您可以从同一GCE网络上的其他主机访问该URL,但仍然无法从Google Compute Engine外部访问该URL,那么您会受到第二个问题的影响。 To fix it, you will need to open the port in the GCE firewall ; 要修复它,您将需要在GCE防火墙中打开该端口 this can also be done via the web UI in the Developers Console . 这也可以通过开发者控制台中的Web UI来完成。

Create an entry in your local ssh config file as below with specific local forward port. 如下所示在本地ssh配置文件中使用特定的本地转发端口创建一个条目。 In my case its an example of yarn's IP, which I want to access in browser. 就我而言,这是一个纱线IP的示例,我想在浏览器中访问它。

Host hadoop
     HostName <External-IP>
     User <Local-machine-username>
     IdentityFile ~/.ssh/<private-key-for-above-user>
     LocalForward 8089 <Internal-IP>:8088

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

相关问题 无法访问谷歌云计算引擎外部 IP 以访问 flask 应用程序 - Can't access Google Cloud Compute engine external IP to access flask app 部署到 Heroku 的应用程序无法远程访问 cPanel 中的 MySQL 数据库 - An app deployed to Heroku can't access to MySQL database in cPanel remotely 使用 Python 从谷歌云中检索已部署应用程序的端点 url - Retrive endpoint url of deployed app from google cloud run with Python Google Cloud App Engine Cron无法执行python脚本 - Google Cloud App Engine Cron can't execute python script 无法访问Docker容器内的烧瓶应用程序 - Can't access flask app which is inside docker container 是否可以在使用 Google Cloud 上的 Docker 部署的 Python web 应用程序中生成声音? - Is it possible to generate sound within a Python web application deployed with Docker on Google Cloud? Google App Engine - 大查询 - Python无法找到google.cloud库 - Google App Engine - Big Query - Python can't find libraries google.cloud 如何从 Python 访问谷歌云 docker 注册表 - How to access google cloud docker registry from Python Google Cloud Dataflow 无法导入“google.cloud.datastore” - Google Cloud Dataflow can't import 'google.cloud.datastore' Google Cloud Run:将多个应用文件打包到一个 docker 映像中 - Google Cloud Run: Packaging multiple app files to one docker image
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM