如何访问mongodb部署的insde lxc容器

时间:2015-08-29 23:30:57

标签: lxc ubuntu-15.04 lxd

我一直在玩lxc-lxd。我能够在lxc容器(ubuntu 15.04)中安装mongodb。我能够从容器内访问所有内容,但不能访问其他方面。容器& lxc-bridge被赋予10.x.x.x ip地址,因为我的网络路由器IP地址以192.x.x.x开头。如何从容器外部访问mongodb(也在主机外部)。我计划为nginx和amp;创建几个容器。 node.js,所以主机传递可能不是一个选项。

我的Ubuntu主机在虚拟机VM中运行,希望这不会导致问题。

1 个答案:

答案 0 :(得分:1)

首先按照https://wiki.debian.org/LXC/SimpleBridge

中的说明创建一个桥梁

我的界面显示的是em1而不是eth0所以请务必将eth0替换为您所拥有的任何内容。

# Comment out the following:
# The primary network interface
#allow-hotplug eth0
#iface eth0 inet dhcp

auto br0
iface br0 inet dhcp
        bridge_ports eth0
        bridge_fd 0
        bridge_maxwait 0

然后使用个人资料创建容器:

lxc profile create bridged
lxc profile device add bridged eth0 nic nictype=bridged parent=br0
lxc launch ubuntu/vivid test --profile=bridged

再次用你得到的东西替换eth0,我认为这是多余的,因为我们已经有一个名为br0的桥,实际上我是按相反的顺序做的。创建了配置文件和容器,但我收到以下错误:

Error calling 'lxd forkstart db01 /var/lib/lxd/containers /var/log/lxd/db01/lxc.conf': err='exit status 1'

通过如上所述创建桥来解决此问题。

相关问题