前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >fedora20 linux container 试用

fedora20 linux container 试用

作者头像
三杯水Plus
发布2018-11-14 15:39:07
8050
发布2018-11-14 15:39:07
举报
文章被收录于专栏:运维运维

Fedora20  lxc 试用

Linux container 是除了xen, kvm,vSphere外的另一种虚拟化选择方案。

What's LXC?

LXC is a userspace interface for the Linux kernel containment features.

Through a powerful API and simple tools, it lets Linux users easily create and manage system or application containers.

Features

Current LXC uses the following kernel features to contain processes:

Kernel namespaces (ipc, uts, mount, pid, network and user)

Apparmor and SELinux profiles

Seccomp policies

Chroots (using pivot_root)

Kernel capabilities

Control groups (cgroups)

As such, LXC is often considered as something in the middle between a chroot on steroids and a full fledged virtual machine. The goal of LXC is to create an environment as close as possible as a standard Linux installation but without the need for a separate kernel.

Components

LXC is currently made of a few separate components:

The liblxc library

Several language bindings (python3, lua and Go)

A set of standard tools to control the containers

Container templates

1,yum -y install lxc*

155041992.png
155041992.png

2,lxc宿主主机配置

首先介绍几个文件夹(默认通过yum安装将自动生成以下文件/文件夹)

1). /etc/lxc/default.conf

创建容器时若未指定配置文件,则默认使用这个default.conf作为该容器的配置文件

2). /usr/share/lxc/templates/

该目录下保存了LXC支持的各种发行版的linux模板,通常有:

155043643.png
155043643.png

3). /var/lib/lxc/

这个目录是用来存放容器实例的,默认情况下该文件夹只有管理员才有权限访问读写其中文件

4). /var/cache/lxc/

第一次创建容器,需要下载一个mini版的容器系统,很快就好了,创建好后,将会在该目录下创建缓存,再次创建直接采用缓存无须再网上下载.

3,检验lxc是否已安装好

lxc-verison

如果显示 lxc version: x.x.x表示安装成功。这里x表示版本号,我安装的是lxc version:0.9.0

lxc-checkconfig

155046488.png
155046488.png

4,lxc基本命令用法

lxc-create -t oracle  -n o1

这里以lxc-oracle为模板,由于本机是fedora20,我发现还可以用lxc-fedora为模板,但是用lxc-ubuntu和lxc-debian时创建时不成功。

创建时需要比较长的时间先到镜像点下载对应镜像我这里是oracle

155048332.png
155048332.png

lxc-start  -n o1

开启容器o1,用oracle用户名,oracle密码登陆

155050254.png
155050254.png

lxc-ls --fancy o1

查看容器基本信息

155052645.png
155052645.png

lxc-console -n o1

连接容器o1,这是lxc容器里面的基本操作,更单独机器差不多,除了网络单独分出来,cpu和内存共享主机的。

155054621.png
155054621.png

lxc-stop -n o1

停止容器o1

还有其他命令,如想加深了解可以看man帮助

155056736.png
155056736.png
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2013-12-30 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
容器服务
腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档