在docker build和docker run之后如何访问我的falcon应用程序? [英] how to visit the my falcon app after docker build and docker run?

查看:214
本文介绍了在docker build和docker run之后如何访问我的falcon应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为> Docker运行无法找到可执行文件"uwsgi"的后续问题一个> :

我已经成功使用Dockerfile执行了docker builddocker run:

I have successfully executed docker build and docker run with the Dockerfile as:

FROM python:2-onbuild

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
ADD . /app

# RUN pip install -r ./requirements.txt
RUN pip install uwsgi

EXPOSE 8000

CMD ["/usr/local/bin/uwsgi", "--http", " :8000" , "--wsgi-file", "falconapp.wsgi"]

我知道它正在运行,因为我在终端上看到了此输出:

I know it's running since I saw this output on terminal:

dacao@Das-MacBook-Pro:~/Documents/bitbucket_2/heatmap_api$ docker run -p 8000:8000 image_heatmap
*** Starting uWSGI 2.0.17 (64bit) on [Tue Mar  6 01:57:52 2018] ***
compiled with version: 4.9.2 on 02 March 2018 19:46:35
os: Linux-4.9.60-linuxkit-aufs #1 SMP Mon Nov 6 16:00:12 UTC 2017
nodename: cc47a3a586e7
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /app
detected binary path: /usr/local/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
*** WARNING: you are running uWSGI without its master process manager ***
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on  :8000 fd 4
spawned uWSGI http 1 (pid: 7)
uwsgi socket 0 bound to TCP address 127.0.0.1:39275 (port auto-assigned) fd 3
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
Python version: 2.7.14 (default, Feb 17 2018, 09:47:19)  [GCC 4.9.2]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x1e966f0
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72920 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0x1e966f0 pid: 1 (default app)
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 1, cores: 1)

我确定Docker映像正在运行:

And I'm sure Docker image is running:

dacao@Das-MacBook-Pro:~/Documents/bitbucket_2/heatmap_api$ docker ps 
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
cc47a3a586e7        image_heatmap       "/usr/local/bin/uwsg…"   16 minutes ago      Up 17 minutes       0.0.0.0:8000->8000/tcp   laughing_nightingale
dacao@Das-MacBook-Pro:~/Documents/bitbucket_2/heatmap_api$ 

接下来,我要检查我的应用程序是否正在实际运行.我在野生动物园浏览器中尝试了以下网址:

Next, I want to check if my app is actually running. I tried the following url on my safari browser:

http://127.0.0.1:8000/healthcheck 
http://localhost:8000/healthcheck 
http://host-ip:8000/healthcheck

但都没有奏效.所有人都给出无法打开页面"错误.
如何访问我的应用程序?

But neither worked. All are giving a 'fail to open page' error.
How to visit the my app?

对不起,我是菜鸟,对Docker真的很陌生

Sorry I am rookie and really new to docker

更新:

我尝试了docker-machine ip,它给出了Error: No machine name(s) specified and no "default" machine exists.我不确定,因为我确定图像正在运行-我用docker ps检查并查看了容器ID图像等.

I tried docker-machine ip and it gives Error: No machine name(s) specified and no "default" machine exists . I don't understand since I'm sure the image is running - I checked with docker ps and see the CONTAINER ID IMAGE , etc.

我也尝试了docker-machine ls,它给出了一个空列表:NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS

I also tried docker-machine ls and it gives empty list: NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS

我应该在执行Docker run ...之前由docker-machine startdocker-machine create default创建一个docker-machine吗?

Am I supposed to create a docker-machine by docker-machine start or docker-machine create default before I do Docker run ... ?

推荐答案

查看启动日志后,问题似乎出在 uWSGI 配置上.

Upon looking at the startup logs, looks like the problem is with uWSGI configuration.

服务器似乎仅从127.0.0.1侦听,这是docker容器内的本地主机.您是否尝试过在 uWSGI 配置中将HOST设置为0.0.0.0?并且不要忘记将端口绑定到主机.

It seems that the server is listening only from 127.0.0.1 which is the localhost inside the docker container. Have you tried setting the HOST to 0.0.0.0 in your uWSGI configuration? And don't forget to bind the port to the host machine.

这篇关于在docker build和docker run之后如何访问我的falcon应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆