问题
我正在构建Python Flask应用程序并将其部署到AWS Elastic Beanstalk。尝试使用
在本地调试应用程序➜ app git:(master) eb local run
它有效,因为控制台显示应用程序正在运行。以下命令还提供了我期望正确的输出。
➜ app git:(master) docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
251b42afa3df 5aebd9e634c4 "python application.p" 7 minutes ago Up 7 minutes 0.0.0.0:8000->8000/tcp 00394e8605902e1b3f216f4df8b5fec348f4b44f
➜ app git:(master) eb local status
Platform: 64bit Amazon Linux 2016.09 v2.3.0 running Docker 1.11.2
Container name: 00394e8605902e1b3f216f4df8b5fec348f4b44f
Container ip: 127.0.0.1
Container running: True
Exposed host port(s): 8000
Full local URL(s): 127.0.0.1:8000
但是,我无法通过浏览器访问该应用。
GET http://127.0.0.1:8000/ net::ERR_CONNECTION_REFUSED
还有wget
,
➜ app git:(master) wget 127.0.0.1:8000
--2017-01-07 11:46:54-- http://127.0.0.1:8000/
Connecting to 127.0.0.1:8000... failed: Connection refused.
详情
我还要注意,当我使用eb deploy
部署到服务器时,应用程序运行良好,可以通过浏览器访问。
➜ app git:(master) eb status
Environment details for: app-env
Application name: app
Region: ap-southeast-2
Deployed Version: app-0eca-170107_111723
Environment ID: e-7tksmeuhun
Platform: 64bit Amazon Linux 2016.09 v2.3.0 running Docker 1.11.2
Tier: WebServer-Standard
CNAME: --snip--.elasticbeanstalk.com
Updated: 2017-01-07 00:18:27.647000+00:00
Status: Ready
Health: Green
我还要注意,运行像下面这样的容器也可以在本地访问。
➜ app git:(master) docker run -p 8000:8000 app
* Running on http://0.0.0.0:8000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger pin code: 166-499-205
我的Dockerrun.aws.json
看起来像这样。说实话,我真的不知道应该完全做什么。
{
"AWSEBDockerrunVersion": "1",
"Volumes": [
{
"ContainerDirectory": "/var/app",
"HostDirectory": "/var/app"
}
],
"Logging": "/var/eb_log"
}
如果有任何其他细节对调试有用,请告诉我 - 我可以提供。提前干杯。