静看光阴荏苒
不管不顾不问不说也不念

Proxmox的LXC容器内运行Docker

因手头上没有空闲的独服了,所以随便找台VPS折腾一下。既KVM虚拟机安装Proxmox,然后用Proxmox开LXC小鸡,LXC小鸡内再安装Docker,无限套娃233

LXC内运行Docker的好处是显而易见的,简而言之LXC比KVM轻很多。以下实验步骤是在Linode的一台1C1G/Debian10上完成的。

安装PVE6.X,装完之后重启:

echo "deb http://download.proxmox.com/debian/pve buster pve-no-subscription" > /etc/apt/sources.list.d/pve-install-repo.list
wget http://download.proxmox.com/debian/proxmox-ve-release-6.x.gpg -O /etc/apt/trusted.gpg.d/proxmox-ve-release-6.x.gpg
apt -y update && apt -y full-upgrade
apt -y install proxmox-ve postfix open-iscsi
reboot

VPS没有多IP,只能开NAT小鸡了,编辑网卡配置文件:

nano /etc/network/interfaces

在原有的配置基础上增加vmbr0网卡的配置即可:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp

auto vmbr0
iface vmbr0 inet static
        address 192.168.0.1
        netmask 255.255.255.0
        bridge_ports none
        bridge_stp off
        bridge_fd 0
        post-up echo 1 > /proc/sys/net/ipv4/ip_forward
        post-up iptables -t nat -A POSTROUTING -s '192.168.0.0/24' -o eth0 -j MASQUERADE
        post-down iptables -t nat -D POSTROUTING -s '192.168.0.0/24' -o eth0 -j MASQUERADE

重启网络服务使更改生效:

systemctl restart networking.service

登录PVE面板后创建小鸡的时候需要注意两点,其一是勾选“无特权的容器”:

其二是配置好网络,桥接vmbr0,设置网关和小鸡的IP:

小鸡创建好了之后,点选项-签名:

勾选嵌套:

配置好了就可以启动了,在LXC内启动几个Docker容器试试看。

跑个NGINX看看:

跑个CentOS8看看:

赞(3)
未经允许不得转载:荒岛 » Proxmox的LXC容器内运行Docker
分享到: 更多 (0)

评论 9

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #1

    博主 同样的linode 安装完访问 https://ip:8006 没反应呢。 是我安装时的选项选的不对吗

    pony4年前 (2020-04-04) Google Chrome 78.0.3904.108 Google Chrome 78.0.3904.108 Windows 7 x64 Edition Windows 7 x64 Edition回复
    • 你可能用了个假Linode :razz: 安装时的那些选项随便怎么选都可以 :neutral:

      LALA4年前 (2020-04-04) Google Chrome 74.0.3729.169 Google Chrome 74.0.3729.169 Windows 10 x64 Edition Windows 10 x64 Edition回复
      • 假的 可还行。

        pony4年前 (2020-04-05) MIUI Browser 9.5.14 MIUI Browser 9.5.14 Android 7.1.1 Android 7.1.1回复
      • 这东西还看人品吗 那个数据中心 没事碰碰运气

        pony4年前 (2020-04-05) MIUI Browser 9.5.14 MIUI Browser 9.5.14 Android 7.1.1 Android 7.1.1回复
        • Fremont

          LALA4年前 (2020-04-05) Google Chrome 74.0.3729.169 Google Chrome 74.0.3729.169 Windows 10 x64 Edition Windows 10 x64 Edition回复
          • 一摸一样。debian10。可能我人品不好。

            pony4年前 (2020-04-05) Safari 12.1 Safari 12.1 iPad iOS 12.2 iPad iOS 12.2
  2. #2

    博主威武 :mrgreen:

    weeper4年前 (2020-04-04) Microsoft Edge 80.0.361.109 Microsoft Edge 80.0.361.109 Windows 10 x64 Edition Windows 10 x64 Edition回复
  3. #3

    大佬我也是pve lxc容器里跑docker想通过公网ipv6远程访问,虚拟机装ikuai作主路由ipv6 DHCPv6都配置好了其他设备都能分配到公网ipv6,就是这个lxc容器只有内网ipv6地址求解怎么获取公网ipv6 :cry:

    yhwhut2年前 (2022-03-18) Google Chrome 99.0.4844.74 Google Chrome 99.0.4844.74 Windows 7 x64 Edition Windows 7 x64 Edition回复

分享创造快乐

广告合作资源投稿