一, 首先配置lxc需要的网卡断

  lxc 容器基础配置篇-LMLPHP

  吧eth0复制一份变为br0

  配置br0

    lxc 容器基础配置篇-LMLPHP

  配置eth0

    lxc 容器基础配置篇-LMLPHP

 重启网卡

  /etc/init.d/network restart

 安装lxc软件 需要epel源---

  yum install  lxc* libcgroup* -y

 安装完成过后:

  lxc 容器基础配置篇-LMLPHP

  启动lxc

 lxc 容器基础配置篇-LMLPHP

  配置lxc源

  lxc 容器基础配置篇-LMLPHP

  lxc 容器基础配置篇-LMLPHP

  lxc 容器基础配置篇-LMLPHP

  复制内容 到命令行擦做

  lxc 容器基础配置篇-LMLPHP

  lxc 容器基础配置篇-LMLPHP

  自己选择自己系统的版本信息,

  主要

    ppc的话事IBM的

    arm64手机那种

    amd63  X64

    i386     X32

  查看下载的文件内容

  lxc 容器基础配置篇-LMLPHP

  下载一个模板

  lxc 容器基础配置篇-LMLPHP

  查看模板信息

  lxc 容器基础配置篇-LMLPHP

  启动lxc

  lxc 容器基础配置篇-LMLPHP

  发现需要登入但是并没有密码

  新建一个连接

  lxc 容器基础配置篇-LMLPHP

  

  

  进去啦...

  lxc 容器基础配置篇-LMLPHP

  发现没有网

  

  lxc配置网络

  新建一个连接配置文件

  lxc 容器基础配置篇-LMLPHP

  重启服务:

  新开连接

  lxc 容器基础配置篇-LMLPHP

  在启动lxc

  更改容器的DNS

    resolve.conf

  新建连接配置容器

    lxc 容器基础配置篇-LMLPHP

  容器中查看已经同步 

    lxc 容器基础配置篇-LMLPHP

  cnetos6 配置地址

  lxc 容器基础配置篇-LMLPHP

  lxc 容器基础配置篇-LMLPHP

  在容器中ping 百度

  

  更改yum源文件

  vim /var/lib/lxc/centos6-muban/rootfs/etc/yum.repos.d/CentOS-Base.repo

  

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
# [base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

  安装ssh

  安装ssh

   yum install openssh-server -y

  ssh远程连接lxc

  

  lxc常用命令:

   lxc -ls 查看lxc容器列表

   lxc-destroy 删除一个容器

   lxc-start 启动   lxc-start -n centos6-muban

   lxc-stop 停止一个容器 lxc-stop -n centos6-muban

     lxc-clone 克隆lxc   lxc-clone centos6-muban web
    lxc 容器基础配置篇-LMLPHP

 

     

 

05-26 22:21