docker build 和 docker run 后如何访问 my falcon 应用程序?

2024-03-03

作为后续问题Docker运行找不到可执行文件“uwsgi” https://stackoverflow.com/questions/49073975/docker-run-cannot-find-executable-uwsgi :

我已经成功执行了docker build and docker runDockerfile 为:

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 很陌生

UPDATE:

I tried 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 吗docker-machine start or docker-machine create default在我做之前Docker run ... ?


容器中的 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://127.0.0.1:8000/healthcheck
http://localhost:8000/healthcheck http://localhost:8000/healthcheck
http://主机IP:8000/healthcheck http://host-ip:8000/healthcheck

如果你想在后台运行容器使用-dit for it:

docker run -dit --name test -p 8000:8000 smaller_runner

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

docker build 和 docker run 后如何访问 my falcon 应用程序? 的相关文章

随机推荐

  • (重新)使用 Visual Studio 2008 在 IE7 中启用 JavaScript 调试器

    Visual Studio 2008 附带了很好的 JavaScript 调试功能 但是我玩了一下 NetBeans 调试器 它在我的 IE 上安装了一个来自 Microsoft 的丑陋的脚本调试器 通常 IE 应该询问我想用什么来调试 但
  • 为什么 iOS 上需要重启才能发送崩溃日志?

    使用自定义的崩溃报告系统 例如专门从事iPhone 崩溃后要求用户发送崩溃日志 https stackoverflow com questions 5392283 ask the user to send crash log after c
  • C#命令获取结构偏移量?

    假设我有一个像这样的 C 结构 StructLayout LayoutKind Explicit struct IMAGE DOS HEADER FieldOffset 60 public int e lfanew 现在假设我从文件中读取数
  • 无法使用 MinGW 构建 Boost,它会寻找 Visual C++

    起初 我尝试使用以下命令构建安装了 MinGW 和 Microsoft Visual C 的 Boost bootstrap bat mingw b2 在构建过程中 我收到了大量日志行 表明构建是针对 Visual C msvc 完成的 所
  • 有没有办法让类名与表名不同?

    我们正在使用几年前创建的数据库 并且希望保持表名称相同 我们所有的表都命名为 tbl Orders 但我们希望模型 控制器等的类名称为 Orders OrdersController 等 我们使用实体框架将类映射到我们的表 抱歉 如果之前有
  • 通过反射访问Java中的私有变量[重复]

    这个问题在这里已经有答案了 我正在尝试编写一个方法 该方法将使用反射在类中获取私有字段 这是我的课程 针对此示例进行了简化 public class SomeClass private int myField public SomeClas
  • 从字符串值设置 Android 图像

    目前我正在 Android 应用程序中绘制 PNG 图像 如下所示 ImageView image new ImageView context image setImageDrawable context getResources getD
  • 向 FormBuilder 添加一个方法,该方法调用呈现部分的辅助方法

    所以我有这个辅助方法 对吧 def table form field name or options nil args block render partial gt snippets table form field locals gt
  • 如何从 webview 打开 safari 移动应用程序中的链接

    这里有很多主题 但它们都需要本机代码交互才能工作 就我而言 有必要能够直接从 URL 执行此操作 而无需与我的移动应用程序进行任何交互 I tried a href target blank Open Google in Safari a
  • 创建非活动 C# WPF 窗口的缩略图

    我在这里浏览了许多主题 并通过谷歌搜索了信息 但没有找到与我的问题相关的任何内容 我想要做的是拥有它 以便当用户启动应用程序时 主窗口 不是 MDI 将打开并显示四个图像框 每个图像框显示当他们单击它时将打开的表单图像 一旦选定的表单打开并
  • 从 C# 运行带有参数的命令行?

    可以使用如下命令在 C 中运行命令行 process new Process process StartInfo FileName command process Start 问题是命令字符串是否包含参数 例如 C My Dir MyFil
  • Ada95 中的线程和信号量

    如何在 Ada95 中使用线程 我可以使用哪些函数来创建 销毁 停止和启动它们 我如何在这种语言中使用信号量 并发性内置于该语言中 因此您可以为任务 即线程 和受保护对象 即比信号量 互斥体 条件变量更强大 使用特定的 Ada 语法 这使得
  • 如何在按钮上添加图像(左)和文本

    如何在按钮上添加图像 左 和文本 举例说明 use android drawableLeft drawable image 在你的布局 xml 中 你也可以从代码中做到这一点 Drawable icon getContext getReso
  • 未调用委托方法“clickedButtonAtIndex:”

    我使用以下代码创建了一个带有两个按钮的警报视图 UIAlertView alertView UIAlertView alloc initWithTitle title message msg delegate nil cancelButto
  • 已删除的类会丢弃错误消息未知>:0:错误:没有这样的文件或目录:

    因此 我和一些朋友正在从事 bitbucket 项目 并且已经意识到 bitbucket 有时不会同步所有文件 但事情是这样的 我继续工作并创建了一个类 我基本上复制了一个旧的视图控制器 称为WelcomescreenViewControl
  • 如何在Unity中制作2D动画

    因此 我正在 Unity 中为 Android 和 iOS 儿童制作 3D 游戏 但我是游戏开发新手 规划资源确实很困难 我们需要创建 2D 动画 纸质角色 并且角色必须具有出色的动画细节 我们一直在考虑几种选择 我们可以创建逐帧动画 但我
  • 使用 AWS Cloudfront 的 hls.js CORS 存在 Cookie 问题

    我正在尝试使用 Cloudfront HLS 功能设置视频流 但我无法让 Hls js 在请求中发送我的凭据 cookie 我已经将 Cloudfront 配置为转发 cookie 和转发访问控制标头 我还设置了 S3 CORS 策略以包括
  • 什么时候在 Java 中使用可变参数?

    我害怕可变参数 我不知道用它们做什么 另外 让人们想传递多少参数就感觉很危险 适合使用它们的上下文示例是什么 Varargs are useful对于任何需要处理的方法不确定数量的物体 一个很好的例子是String format http
  • 使用正则表达式 python 查找电子邮件[重复]

    这个问题在这里已经有答案了 我想在文本文件中查找有效的电子邮件地址 这是我的代码 email re findall r a zA Z w line 但我的代码显然不包含 符号之前有数字的电子邮件地址 我的代码无法处理没有有效结尾的电子邮件地
  • docker build 和 docker run 后如何访问 my falcon 应用程序?

    作为后续问题Docker运行找不到可执行文件 uwsgi https stackoverflow com questions 49073975 docker run cannot find executable uwsgi 我已经成功执行了