作为Docker run cannot find executable "uwsgi"的后续问题 :
我已使用Dockerfile成功执行docker run
和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"]
:
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)
我知道自从我在终端上看到此输出后它正在运行:
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$
我确定Docker镜像正在运行:
http://127.0.0.1:8000/healthcheck
http://localhost:8000/healthcheck
http://host-ip:8000/healthcheck
接下来,我想检查一下我的应用是否真的在运行。我在我的safari浏览器上尝试了以下网址:
docker-machine ip
但都没有奏效。所有人都打不开页面'错误。
如何访问我的应用程序?
对不起,我是新手,对船坞人来说真是个新手
更新:
我尝试了Error: No machine name(s) specified and no "default" machine exists
并提供了docker ps
。我不明白,因为我确定图片正在运行 - 我查看了docker-machine ls
并查看了容器ID图片等。
我还尝试了NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
,它提供了空列表:docker-machine start
我应该在docker-machine create default
Docker run ...
之前按select user.id
from user
inner join computer on user.id=computer.user_id and computer.name='Macintosh'
inner join component on computer.id=component.computer_id
and component.componentName='ram'
and component.componentValue = '16GB'
或select user.id
from user
inner join computer on user.id=computer.user_id and computer.name='Macintosh'
and computer.id not (
select component.computer_id
from component
where component.componentName='ram'
and component.componentValue <> '16GB')
创建一个泊坞机吗?
答案 0 :(得分:0)
容器中的HTTP服务器正在端口8000上运行,因此如果要在主机上看到它,则必须使用以下模式发布端口:
docker run -p <host-port>:<container-port> smaller_runner
因此,如果要在端口8000上访问主机上的容器,则必须运行此命令:
docker run -p 8000:8000 smaller_runner
然后你可以查看其中一个网址:
http://127.0.0.1:8000/healthcheck
http://localhost:8000/healthcheck
http://host-ip:8000/healthcheck
如果你想在后台使用-dit
运行容器:
docker run -dit --name test -p 8000:8000 smaller_runner
答案 1 :(得分:0)
在查看启动日志时,看起来问题出在 uWSGI 配置上。
服务器似乎仅从127.0.0.1
侦听,HOST
是docker容器内的localhost。您是否尝试过在 uWSGI 配置中将0.0.0.0
设置为{{1}}?并且不要忘记将端口绑定到主机。