目录
容器技术
前一篇文章介绍了,所谓容器,简单来说是一组资源隔离、资源受限的进程。核心技术使用了Linux内核中的Namespa 和Cgroup。
即利用Linux内核我们就能创建所谓的容器。下面介绍下如何使用lxc来创建简单的容器
LXC
LXC(Linux Containers),即Linux容器,是一个操作系统层面的虚拟化技术。利用Linux内核中的CGroup + Namespace + Chroot技术,其中CGroup提供资源隔离,Namespace提供命名空间隔离,而Chroot是最简单和古老的容器化技术,更改了进程的根目录,限制访问和可见性,把容器内所有的依赖的程序/文件复制到单独的目录中。
#CentOs7.5
#1. 按照lxc lxc-templates
> yum install lxc lxc-templates
#2. lxc-checkconfig ==> cgroup + namespace必须启动
> lxc-checkconfig
Kernel configuration not found at /proc/config.gz; searching...
Kernel configuration found at /boot/config-3.10.0-862.3.2.el7.x86_64
--- Namespaces ---
Namespaces: enabled
Utsname namespace: enabled
Ipc namespace: enabled
Pid namespace: enabled
User namespace: enabled
newuidmap is not installed
newgidmap is not installed
Network namespace: enabled
Multiple /dev/pts instances: enabled
--- Control groups ---
Cgroup: enabled
Cgroup clone_children flag: enabled
Cgroup device: enabled
Cgroup sched: enabled
Cgroup cpu account: enabled
Cgroup memory controller: enabled
Cgroup cpuset: enabled
--- Misc ---
Veth pair device: enabled
Macvlan: enabled
Vlan: enabled
Bridges: enabled
Advanced netfilter: enabled
CONFIG_NF_NAT_IPV4: enabled
CONFIG_NF_NAT_IPV6: enabled
CONFIG_IP_NF_TARGET_MASQUERADE: enabled
CONFIG_IP6_NF_TARGET_MASQUERADE: enabled
CONFIG_NETFILTER_XT_TARGET_CHECKSUM: enabled
--- Checkpoint/Restore ---
checkpoint restore: enabled
CONFIG_FHANDLE: enabled
CONFIG_EVENTFD: enabled
CONFIG_EPOLL: enabled
CONFIG_UNIX_DIAG: enabled
CONFIG_INET_DIAG: enabled
CONFIG_PACKET_DIAG: enabled
CONFIG_NETLINK_DIAG: enabled
File capabilities: enabled
Note : Before booting a new kernel, you can check its configuration
usage : CONFIG=/path/to/config /bin/lxc-checkconfig
#3. 安装了lxc-templates,默认支持以下容器模板
> ls -l /usr/share/lxc/templates/
总用量 340
-rwxr-xr-x 1 root root 10579 3月 7 2019 lxc-alpine
-rwxr-xr-x 1 root root 13537 3月 7 2019 lxc-altlinux
-rwxr-xr-x 1 root root 10839 3月 7 2019 lxc-archlinux
-rwxr-xr-x 1 root root 9677 3月 7 2019 lxc-busybox
-rwxr-xr-x 1 root root 29971 3月 7 2019 lxc-centos
-rwxr-xr-x 1 root root 10486 3月 7 2019 lxc-cirros
-rwxr-xr-x 1 root root 18342 3月 7 2019 lxc-debian
-rwxr-xr-x 1 root root 18064 3月 7 2019 lxc-download
-rwxr-xr-x 1 root root 49438 3月 7 2019 l

最低0.47元/天 解锁文章
1881

被折叠的 条评论
为什么被折叠?



