[英]Can't access the dockerized app launched from the command line from outside
I have built a Docker image with Ruby and some gems as a starting point for my projects. 我已经使用Ruby和一些gems构建了一个Docker镜像,以此作为我项目的起点。 Its available at: jikkujose/trial
. 可在以下位置jikkujose/trial
它: jikkujose/trial
。 I am trying this out in a Mac, using the default docker-toolbox. 我正在使用默认的docker-toolbox在Mac中进行尝试。
I am trying to use it to host a single file app. 我正在尝试使用它来托管单个文件应用程序。 I am launching it as follows: 我按如下方式启动它:
docker run -itdP -v .:/app jikkujose/docker
The current directory contains a file app.rb
with the following: 当前目录包含一个文件app.rb
,其中包含以下内容:
require 'sinatra'
class App < Sinatra::Base
set :bind, "0.0.0.0"
get '/' do
'This is interesting :)'
end
end
App.run!
I am able to attach to the container to launch the app. 我可以附加到容器上以启动应用程序。 And the following is seen when I do: docker ps -a
当我这样做时,将看到以下内容: docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
92498cafd985 jikkujose/trial "/bin/bash" 18 seconds ago Up 18 seconds 0.0.0.0:32780->4567/tcp boring_meitner
And I am trying to access the application using the ip obtained via docker-machine ip default
. 我正在尝试使用通过docker-machine ip default
获取的ip访问应用程序。
While trying to access the the app using curl
, I am getting the following: 尝试使用curl
访问应用程序时,出现以下情况:
curl: (7) Failed to connect to 192.168.99.100 port 32780: Connection refused
Failed to connect to 192.168.99.100 port 32780: Connection refused
That should mean there is no listener, or, since a docker exec <container id> curl http://localhost:4567
does work, that the listener does not accept queries from broadcast, only from localhost... 这应该意味着没有侦听器,或者由于docker exec <container id> curl http://localhost:4567
确实起作用,所以侦听器不接受来自广播的查询,仅接受来自本地主机的查询...
Your entrypoint and cmd are : 您的入口点和cmd为 :
ENTRYPOINT ["/opt/rubies/ruby-2.2.2/bin/ruby"]
CMD ["/app/app.rb"]
Check if others mean to launch a sinatra app would work better with a docker environment: for instance " Dockerizing simple Sinatra app using docker and fig " (fig is the old name of docker compose) 检查是否有其他人打算启动sinatra应用程序在docker环境下更好地工作:例如“使用docker和fig进行简单的Sinatra应用程序Docker化 ”(fig是docker compose的旧名称)
Before that, check if the mapped port is forwarded at the VirtualBox level : 在此之前,请检查是否在VirtualBox级别转发了映射的端口:
VBoxManage controlvm boot2docker-vm natpf1 "name,tcp,127.0.0.1,32780,,32780"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.