无法从网络上的其他计算机浏览Dockerized Web应用程序 [英] Cannot browse dockerized web app from other computers on network

查看:107
本文介绍了无法从网络上的其他计算机浏览Dockerized Web应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望与Mac在同一网络上的任何计算机都能够访问在Mac上运行的dockerized Rails Web应用.

I would like any computer on the same network as my Mac to be able to access the dockerized Rails web app running on my Mac.

在我的Mac(10.9.5)上,当我通过docker ip和我分配的端口192.168.99.100:3000

On my Mac (10.9.5) my Rails 4.2.4 web app is running fine in Docker when I access it via the docker ip and the port I assigned, 192.168.99.100:3000

Docker 1.8.1在Virtualbox 5.0.2下运行.

Docker 1.8.1 is running under Virtualbox 5.0.2.

我正在使用Docker-compose,而docker-compose.yml文件的相关部分是:

I'm using Docker-compose and the relevant part of the docker-compose.yml file is:

web:
  build: .
  command: 'bash -c ''bundle exec unicorn -p $PORT -c ./config/unicorn-local.rb'''
  working_dir: /app/user
  env_file:
    - .docker_dev_env_config
    - .docker_dev_env_personal
  environment:
    PORT: 3000
    DATABASE_URL: 'postgres://postgres:@herokuPostgresql:5432/postgres'
  ports:
    - '3000:3000'
  links:
    - herokuPostgresql

我的Dockerfile是

and my Dockerfile is

FROM heroku-ruby2.0.0 # a local image based on heroku/ruby with ruby 2.0.0
EXPOSE 3000
ENV widget foo

我的Mac在本地网络上的IP地址始终设置为192.168.0.33.

My Mac's ip address on the local network is always set to 192.168.0.33.

如何允许本地网络上的测试人员通过192.168.0.33:3000访问正在运行的dockerized应用?

How do I permit testers on the local network to access the running dockerized app via 192.168.0.33:3000 ?

(FWIW,如果我在Vagrant下运行我的Web应用程序-而不是Docker-网络上的其他测试人员可以通过浏览192.168.0.33:3000访问该Web应用程序.我的Vagrant也正在Virtualbox下运行.我的Vagrantfile包含config.vm.network :forwarded_port, guest: 3000, host: 3000但我看不到docker-compose.yml的任何等效内容

(FWIW if I run my web app under Vagrant - instead of Docker - other testers on the network can access the web app by browsing 192.168.0.33:3000. My Vagrant is also running under Virtualbox. My Vagrantfile contains config.vm.network :forwarded_port, guest: 3000, host: 3000 but I do not see any equivalent for docker-compose.yml)

推荐答案

使用docker-toolkit的Docker Quickstart Terminal应用程序创建的默认"虚拟箱除定义的ssh外没有其他端口.

The 'default' Virtualbox created when using docker-toolkit's Docker Quickstart Terminal app does not have any port other than an ssh defined.

在Mac上将VirtualBox与Docker结合使用时的解决方案是:

The solution on the Mac, when using VirtualBox with Docker is:

  • 运行VirtualBox
  • 单击默认"框(或Docker安装程序使用的任何框)
  • 转到设置>网络>适配器1
  • 点击端口转发"
  • 创建一个新规则,下面的示例从3000到3000 (确保将主机ip列留空)
  • Run VirtualBox
  • click the 'default' box (or whichever box your Docker setup uses)
  • go to 'Settings > Network > Adapter 1
  • click 'Port Forwarding'
  • create a new rule the example below fwds 3000 to 3000 (be sure to leave the host ip column blank)

这篇关于无法从网络上的其他计算机浏览Dockerized Web应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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