纸上得来终觉浅:lxc初体验

in #cn5 years ago

最近尝试去了解一下Linux下的虚拟机以及容器之类的内容,知道了lxc、lxd这些神奇的东西,lxc是Linux Container的缩写,简单的来讲在内核的基础上进行轻量级虚拟化,以便隔离进程和资源。


(图源 :pixabay)

lxd是lxc的进化版,先试试lxc吧。

安装 lxc

先来安装一下试试:

sudo apt install lxc

从提示信息可见,它还一并安装了bridge-utils libpam-cgfs lxc-utils这三个东东

安装 lxc-templates

安装之后查看一下模板信息:

ls /usr/share/lxc/templates/

发现只有这么四个东东,没有Ubuntu啊

于是再安装lxc-templates

sudo apt install lxc-templates

好嘛,这就是传说中的全家桶嘛?

装完之后模板果然多了好多

创建Container

接下来使用如下命令创建容器:

sudo lxc-create -t ubuntu -n xxx

接下来大量的信息以及漫长的等待,这个过程更有点像网络安装ubuntu系统:

快完成后有这样两句输出,这就相当于烧写磁盘啦

Copy /var/cache/lxc/bionic/rootfs-amd64 to /var/lib/lxc/xxx/rootfs ...
Copying rootfs to /var/lib/lxc/xxx/rootfs ...

最后这段写着初始用户名和密码,也很重要,之后登录要用到这个

查看Container

我们可以使用如下命令查看我们已经创建的lxc 容器。

sudo lxc-ls

进入Container

我们可以使用如下命令进入到Container界面

sudo lxc-console -n xxx

这两个特别的指令要记一下:

登录成功后发现和正常安装的Ubuntu没啥区别

其它

使用uname -a可以看到内核版本与主机的版本是一样的。

使用lscpu可以看到CPU信息和主机是完全一致的。

如果想使用ifconfig查看网络信息则需要先安装net-tools

sudo apt install net-tools

总之,看起来也挺好玩的,不过据说现在已经没谁玩啦,哈哈。

相关链接


Vote For Me As Witness
https://steemit.com/~witnesses type in oflyhigh and click VOTE

Vote @oflyhigh via Steemconnect
Thank you!

Sort:  

Thank you so much for participating in the Partiko Delegation Plan Round 1! We really appreciate your support! As part of the delegation benefits, we just gave you a 3.23% upvote! Together, let’s change the world!

Downvoting due to suspected vote trading.

Hi @transisto,
I didn't do any voting trading.
Why did you downvoted my post just because it was "suspected vote trading"?

I spent most of the day testing LXC and probably an hour or two writing this post.
This post is very helpful to anyone who needs to know about LXC.
And I think this post also adds value to steem.

You know it's always easier to destroy than to build.
If a valuable post is trampled for a fictitious reason, Then the author must be hurt, enthusiasm must be hit.If the authors all leave steem, how will steem be valued?

I hope you can read this post carefully and the cancel the downvote.
Thank you.

He’s doing it to everyone. He thinks he’s the Steemit Emperor. I have manual curated about 200 posts in the last two days and removed my auto vote bot for everyone. I didn’t cast one vote for anyone on my bot and he still down votes all my posts. #bitchmade

We all have been on steem a long time.
I think everyone who stays on steem has a deep affection for steem.
Otherwise wasted half a day to write a post is really worth it?

In addition, I think the author and the article are what makes steem valuable.
I think through communication, @transisto will also realize this, because we all love steem, wish steem better!

Of course I love Steem, I been here everyday for about 2.5 years. Never sold a Token. I only voted content I liked but i did vote for the same people everyday for a while (it changed often). Those voters also voted me. I liked the content they posted, I think @adsactly and @czechglobalhosts @slowwalker bring great content everyday and I think it’s good for Steem. I never asked ANY of them for votes, I voted them and they started voting me. I put them on my auto voter. Then Phar, acid,ocd,cure,transisto, and many others ganged up on me to get me to stop.....so I decided to stop with the bot, I quit self vote, told my mom to find other supporters for her blog......and they still downvoted me and others who have done the same. They are bigger circle jerkers than anyone here....they just hide it well by covering retaliation votes. Steemit is doomed with these guys doing this stuff. I used to care about Steemit.....I care less and less everyday. Soon I will be driven to help bring it down as much as I can. It’s stupid what’s happening.

More than three years ago, on the recommendation of a friend I join the STEEM, and from then on it became an indispensable part of my life.

I record my happiness and sadness on steem, record my study of steem, record my study of block chain, record my study of programming, and so on.

This has even become a habit, even though I've been earning less than 0.1SBD per post for several times.

I've titled my series of posts: Make a Little Progress Every Day(每天进步一点点).
Sometimes I feel very tired, but think how we can make progress if we don't insist?I hope that I can make progress, that sharing valuable content can help others, and that I can add value to STEEM.

I have never bought upvote from any bit bot, Don't know why is considered vote trading.

And for @slowwalker, I made a comment here:
https://steemit.com/dblog/@oflyhigh/q0djp2
I don't think that's vote tradeing.
If we can't support our favorite authors and content on social networking sites, should we support some junk content?

Steemit != Steem, You should know that by now.


You're voting these automated reports, good reason to hit you where it hurt, Flagging these small post is a waste of VP, so I'm flagging the bigger ones.


You're voting these automated reports, good reason to hit you where it hurt, Flagging these small post is a waste of VP, so I'm flagging the bigger ones.

Coin Marketplace

STEEM 0.25
TRX 0.25
JST 0.039
BTC 95803.39
ETH 3334.91
USDT 1.00
SBD 3.31