作为Docker run cannot find executable "uwsgi"的后续问题 :
我已成功执行docker build
,并且docker run
Dockerfile 为:
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)
而且我确定 Docker 映像正在运行:
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$
接下来,我想检查我的应用程序是否真的在运行。我在我的 Safari 浏览器上尝试了以下网址:
http://127.0.0.1:8000/healthcheck
http://localhost:8000/healthcheck
http://host-ip:8000/healthcheck
但都没有奏效。所有人都给出了“无法打开页面”错误。
如何访问我的应用程序?
对不起,我是菜鸟,对 docker 很陌生
更新:
我试过docker-machine ip
了,它给出了Error: No machine name(s) specified and no "default" machine exists
. 我不明白,因为我确定图像正在运行 - 我检查docker ps
并查看了 CONTAINER ID IMAGE 等。
我也试过docker-machine ls
了,它给出了空列表:NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
我应该在我之前docker-machine start
或docker-machine create default
之前创建一个 docker-machineDocker run ...
吗?