前一篇博文中主要说了下,lxc容器在Linux上的简单管理,回顾请参考https://www.cnblogs.com/qiuhom-1874/p/12901493.html;今天我们来介绍下lxc的图像管理工具LXC WEB Panel;
项目下载地址:https://github.com/lxc-webpanel/LXC-Web-Panel.git;
1、安装python-flask
[root@lxc ~]# yum install python-flask Loaded plugins: fastestmirror base | 3.6 kB 00:00:00 epel | 4.7 kB 00:00:00 extras | 2.9 kB 00:00:00 updates | 2.9 kB 00:00:00 (1/2): epel/x86_64/updateinfo | 1.0 MB 00:00:00 (2/2): epel/x86_64/primary_db | 6.8 MB 00:00:01 Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package python-flask.noarch 1:0.10.1-5.el7_7 will be installed --> Processing Dependency: python-werkzeug for package: 1:python-flask-0.10.1-5.el7_7.noarch --> Processing Dependency: python-jinja2 for package: 1:python-flask-0.10.1-5.el7_7.noarch --> Processing Dependency: python-itsdangerous for package: 1:python-flask-0.10.1-5.el7_7.noarch --> Running transaction check ---> Package python-itsdangerous.noarch 0:0.23-2.el7 will be installed ---> Package python-jinja2.noarch 0:2.7.2-4.el7 will be installed --> Processing Dependency: python-babel >= 0.8 for package: python-jinja2-2.7.2-4.el7.noarch --> Processing Dependency: python-markupsafe for package: python-jinja2-2.7.2-4.el7.noarch ---> Package python-werkzeug.noarch 0:0.9.1-2.el7 will be installed --> Running transaction check ---> Package python-babel.noarch 0:0.9.6-8.el7 will be installed ---> Package python-markupsafe.x86_64 0:0.11-10.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ========================================================================================== Package Arch Version Repository Size ========================================================================================== Installing: python-flask noarch 1:0.10.1-5.el7_7 extras 205 k Installing for dependencies: python-babel noarch 0.9.6-8.el7 base 1.4 M python-itsdangerous noarch 0.23-2.el7 extras 24 k python-jinja2 noarch 2.7.2-4.el7 base 519 k python-markupsafe x86_64 0.11-10.el7 base 25 k python-werkzeug noarch 0.9.1-2.el7 extras 562 k Transaction Summary ========================================================================================== Install 1 Package (+5 Dependent packages) Total download size: 2.7 M Installed size: 12 M Is this ok [y/d/N]: y Downloading packages: (1/6): python-flask-0.10.1-5.el7_7.noarch.rpm | 205 kB 00:00:00 (2/6): python-itsdangerous-0.23-2.el7.noarch.rpm | 24 kB 00:00:00 (3/6): python-babel-0.9.6-8.el7.noarch.rpm | 1.4 MB 00:00:00 (4/6): python-markupsafe-0.11-10.el7.x86_64.rpm | 25 kB 00:00:00 (5/6): python-jinja2-2.7.2-4.el7.noarch.rpm | 519 kB 00:00:00 (6/6): python-werkzeug-0.9.1-2.el7.noarch.rpm | 562 kB 00:00:00 ------------------------------------------------------------------------------------------ Total 3.0 MB/s | 2.7 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : python-werkzeug-0.9.1-2.el7.noarch 1/6 Installing : python-itsdangerous-0.23-2.el7.noarch 2/6 Installing : python-babel-0.9.6-8.el7.noarch 3/6 Installing : python-markupsafe-0.11-10.el7.x86_64 4/6 Installing : python-jinja2-2.7.2-4.el7.noarch 5/6 Installing : 1:python-flask-0.10.1-5.el7_7.noarch 6/6 Verifying : python-markupsafe-0.11-10.el7.x86_64 1/6 Verifying : python-babel-0.9.6-8.el7.noarch 2/6 Verifying : python-itsdangerous-0.23-2.el7.noarch 3/6 Verifying : python-jinja2-2.7.2-4.el7.noarch 4/6 Verifying : 1:python-flask-0.10.1-5.el7_7.noarch 5/6 Verifying : python-werkzeug-0.9.1-2.el7.noarch 6/6 Installed: python-flask.noarch 1:0.10.1-5.el7_7 Dependency Installed: python-babel.noarch 0:0.9.6-8.el7 python-itsdangerous.noarch 0:0.23-2.el7 python-jinja2.noarch 0:2.7.2-4.el7 python-markupsafe.x86_64 0:0.11-10.el7 python-werkzeug.noarch 0:0.9.1-2.el7 Complete! [root@lxc ~]#
提示:LXC WEB Panel是用flask框架研发,所以依赖python-flask这个包,当然也可以用pip去下载这个也是可以的
pip安装flask,首先要安装python-pip
[root@docker_node1 ~]# yum install python-pip Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package python2-pip.noarch 0:8.1.2-12.el7 will be installed --> Processing Dependency: python-setuptools for package: python2-pip-8.1.2-12.el7.noarch --> Running transaction check ---> Package python-setuptools.noarch 0:0.9.8-7.el7 will be installed --> Processing Dependency: python-backports-ssl_match_hostname for package: python-setuptools-0.9.8-7.el7.noarch --> Running transaction check ---> Package python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7 will be installed --> Processing Dependency: python-ipaddress for package: python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch --> Processing Dependency: python-backports for package: python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch --> Running transaction check ---> Package python-backports.x86_64 0:1.0-8.el7 will be installed ---> Package python-ipaddress.noarch 0:1.0.16-2.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================== Package Arch Version Repository Size ======================================================================================== Installing: python2-pip noarch 8.1.2-12.el7 epel 1.7 M Installing for dependencies: python-backports x86_64 1.0-8.el7 base 5.8 k python-backports-ssl_match_hostname noarch 3.5.0.1-1.el7 base 13 k python-ipaddress noarch 1.0.16-2.el7 base 34 k python-setuptools noarch 0.9.8-7.el7 base 397 k Transaction Summary ======================================================================================== Install 1 Package (+4 Dependent packages) Total download size: 2.1 M Installed size: 9.4 M Is this ok [y/d/N]: y Downloading packages: (1/5): python-backports-1.0-8.el7.x86_64.rpm | 5.8 kB 00:00:00 (2/5): python-ipaddress-1.0.16-2.el7.noarch.rpm | 34 kB 00:00:00 (3/5): python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch. | 13 kB 00:00:00 (4/5): python-setuptools-0.9.8-7.el7.noarch.rpm | 397 kB 00:00:00 (5/5): python2-pip-8.1.2-12.el7.noarch.rpm | 1.7 MB 00:00:00 ---------------------------------------------------------------------------------------- Total 2.3 MB/s | 2.1 MB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : python-backports-1.0-8.el7.x86_64 1/5 Installing : python-ipaddress-1.0.16-2.el7.noarch 2/5 Installing : python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch 3/5 Installing : python-setuptools-0.9.8-7.el7.noarch 4/5 Installing : python2-pip-8.1.2-12.el7.noarch 5/5 Verifying : python-ipaddress-1.0.16-2.el7.noarch 1/5 Verifying : python-setuptools-0.9.8-7.el7.noarch 2/5 Verifying : python2-pip-8.1.2-12.el7.noarch 3/5 Verifying : python-backports-1.0-8.el7.x86_64 4/5 Verifying : python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch 5/5 Installed: python2-pip.noarch 0:8.1.2-12.el7 Dependency Installed: python-backports.x86_64 0:1.0-8.el7 python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7 python-ipaddress.noarch 0:1.0.16-2.el7 python-setuptools.noarch 0:0.9.8-7.el7 Complete! [root@docker_node1 ~]# pip -V pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7) [root@docker_node1 ~]#
提示:默认yum安装的pip默认是python2.7的pip版本是8.1.2,我们使用pip安装flask会提示我们pip版本低,如果你不想看到提示我们版本pip版本过低可以选择pip install --upgrade pip命令对pip进行版本更新
安装flask
[root@docker_node1 ~]# pip install flask Collecting flask Downloading https://files.pythonhosted.org/packages/f2/28/2a03252dfb9ebf377f40fba6a7841b47083260bf8bd8e737b0c6952df83f/Flask-1.1.2-py2.py3-none-any.whl (94kB) 100% |████████████████████████████████| 102kB 11kB/s Collecting Jinja2>=2.10.1 (from flask) Downloading https://files.pythonhosted.org/packages/30/9e/f663a2aa66a09d838042ae1a2c5659828bb9b41ea3a6efa20a20fd92b121/Jinja2-2.11.2-py2.py3-none-any.whl (125kB) 100% |████████████████████████████████| 133kB 10kB/s Collecting itsdangerous>=0.24 (from flask) Downloading https://files.pythonhosted.org/packages/76/ae/44b03b253d6fade317f32c24d100b3b35c2239807046a4c953c7b89fa49e/itsdangerous-1.1.0-py2.py3-none-any.whl Collecting click>=5.1 (from flask) Downloading https://files.pythonhosted.org/packages/d2/3d/fa76db83bf75c4f8d338c2fd15c8d33fdd7ad23a9b5e57eb6c5de26b430e/click-7.1.2-py2.py3-none-any.whl (82kB) 100% |████████████████████████████████| 92kB 10kB/s Collecting Werkzeug>=0.15 (from flask) Downloading https://files.pythonhosted.org/packages/cc/94/5f7079a0e00bd6863ef8f1da638721e9da21e5bacee597595b318f71d62e/Werkzeug-1.0.1-py2.py3-none-any.whl (298kB) 100% |████████████████████████████████| 307kB 9.8kB/s Collecting MarkupSafe>=0.23 (from Jinja2>=2.10.1->flask) Downloading https://files.pythonhosted.org/packages/fb/40/f3adb7cf24a8012813c5edb20329eb22d5d8e2a0ecf73d21d6b85865da11/MarkupSafe-1.1.1-cp27-cp27mu-manylinux1_x86_64.whl Installing collected packages: MarkupSafe, Jinja2, itsdangerous, click, Werkzeug, flask Successfully installed Jinja2-2.11.2 MarkupSafe-1.1.1 Werkzeug-1.0.1 click-7.1.2 flask-1.1.2 itsdangerous-1.1.0 You are using pip version 8.1.2, however version 20.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. [root@docker_node1 ~]# pip list|grep "Flask" Flask (1.1.2) You are using pip version 8.1.2, however version 20.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. [root@docker_node1 ~]#
提示:可以看到flask已经安装,版本是1.1.2
2、安装debootstrap
[root@docker_node1 ~]# yum install -y debootstrap Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package debootstrap.noarch 0:1.0.109-2.el7 will be installed --> Processing Dependency: dpkg for package: debootstrap-1.0.109-2.el7.noarch --> Running transaction check ---> Package dpkg.x86_64 0:1.18.25-9.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================== Package Arch Version Repository Size ======================================================================================== Installing: debootstrap noarch 1.0.109-2.el7 epel 84 k Installing for dependencies: dpkg x86_64 1.18.25-9.el7 epel 1.3 M Transaction Summary ======================================================================================== Install 1 Package (+1 Dependent package) Total download size: 1.4 M Installed size: 6.2 M Downloading packages: (1/2): debootstrap-1.0.109-2.el7.noarch.rpm | 84 kB 00:00:00 (2/2): dpkg-1.18.25-9.el7.x86_64.rpm | 1.3 MB 00:00:00 ---------------------------------------------------------------------------------------- Total 2.6 MB/s | 1.4 MB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : dpkg-1.18.25-9.el7.x86_64 1/2 Installing : debootstrap-1.0.109-2.el7.noarch 2/2 Verifying : debootstrap-1.0.109-2.el7.noarch 1/2 Verifying : dpkg-1.18.25-9.el7.x86_64 2/2 Installed: debootstrap.noarch 0:1.0.109-2.el7 Dependency Installed: dpkg.x86_64 0:1.18.25-9.el7 Complete! [root@docker_node1 ~]#
提示:在创建ubuntu容器时,需要依赖debootstrap;
3、安装LXC组件
请参考https://www.cnblogs.com/qiuhom-1874/p/12901493.html;如果你的主机已经安装这一步可以跳过
4、克隆LXC WEB Panel项目到本地
[root@docker_node1 ~]# git clone https://github.com/lxc-webpanel/LXC-Web-Panel.git Cloning into 'LXC-Web-Panel'... remote: Enumerating objects: 243, done. remote: Total 243 (delta 0), reused 0 (delta 0), pack-reused 243 Receiving objects: 100% (243/243), 198.33 KiB | 205.00 KiB/s, done. Resolving deltas: 100% (108/108), done. [root@docker_node1 ~]# ls LXC-Web-Panel [root@docker_node1 ~]# cd LXC-Web-Panel/ [root@docker_node1 LXC-Web-Panel]#
5、启动LXC WEB Panel
提示:成功启动LXC WEB Panel后,会像上图一样,提示我们访问本机的5000端口;
到此LXC WEB Panel就搭建好了,接下来我们就可以访问5000端口,登录LXC WEB Panel来管理我们的LXC容器了;
提示:默认用户名和密码是admin
提示:登录LXC WEB Panel后,在没有容器的情况下会提示我们创建容器,这里需要注意的是,如果你的主机上没有虚拟的网桥,要创建网桥,在新建容器,否则新建的容器无法启动;
新建网桥请参考https://www.cnblogs.com/qiuhom-1874/p/12901493.html;本人用图形界面去创建网络会报错,不知道哪里的原因;只好手动去Linux shell终端上创建好了;
创建好网桥后,再来启动刚才创建好的容器,就可以正常启动了
提示:可以看到我们创建了网桥后就可以正常启动容器了;如果你主机上有其他网桥也是可以的,我们可以编辑u1,把你主机上有的网桥和类型对应起来,给定一个ip地址,然后启动就没有问题;如下所示
提示:link其他网络需要注意类型,上面docker0桥同virbr0都是虚拟网桥,所以类型是veth;这里还需要注意,如果类型填错了,会导致服务不可用,解决办法是删除/var/lib/lxc/对应容器的名的目录,然后重新启动 LXC WEB Penal;以上就是 LXC的图形管理工具LXC WEB Penal的简单管理,更多的管理可以自己搭建一个玩玩;