2017/5/24

lxc. debian wheezy..

ref: https://linuxcontainers.org/lxc/getting-started/
template : download, 會去 download 新的,所有的 template..然後列出來..
~$ sudo lxc-create -n download -t download
Setting up the GPG keyring
Downloading the image index

---
DIST RELEASE ARCH VARIANT BUILD
---
centos 6 amd64 default 20170504_02:16
centos 6 i386 default 20170504_02:16
centos 7 amd64 default 20170504_02:16
debian jessie amd64 default 20170504_02:41
debian jessie arm64 default 20170504_22:42
debian jessie armel default 20170505_09:10
debian jessie armhf default 20170504_02:41
debian jessie i386 default 20170505_04:24
debian jessie powerpc default 20170503_22:42
debian jessie ppc64el default 20170429_22:42
debian jessie s390x default 20170504_22:42
debian sid amd64 default 20170504_22:42
debian sid arm64 default 20170504_22:42
debian sid armel default 20170505_09:10
debian sid armhf default 20170504_22:42
debian sid i386 default 20170504_02:41
debian sid powerpc default 20170504_22:42
debian sid ppc64el default 20170429_22:42
debian sid s390x default 20170504_22:42
debian stretch amd64 default 20170504_02:41
debian stretch arm64 default 20170504_22:42
debian stretch armel default 20170505_04:24
debian stretch armhf default 20170504_22:42
debian stretch i386 default 20170505_04:24
debian stretch powerpc default 20161104_22:42
debian stretch ppc64el default 20170429_22:42
debian stretch s390x default 20170504_22:42
debian wheezy amd64 default 20170505_09:10
debian wheezy armel default 20170504_22:42
debian wheezy armhf default 20170504_22:42
debian wheezy i386 default 20170504_22:42
debian wheezy powerpc default 20170504_22:42
debian wheezy s390x default 20170504_22:42
fedora 22 amd64 default 20170216_01:27
fedora 22 i386 default 20170216_02:15
fedora 23 amd64 default 20170215_03:33
fedora 23 i386 default 20170215_01:27
fedora 24 amd64 default 20170505_01:59
fedora 24 i386 default 20170505_01:27
fedora 25 amd64 default 20170505_02:42
fedora 25 i386 default 20170504_01:27
gentoo current amd64 default 20170503_14:12
gentoo current i386 default 20170504_14:12
oracle 6 amd64 default 20170505_11:40
oracle 6 i386 default 20170505_12:47
oracle 7 amd64 default 20170505_12:47
plamo 5.x amd64 default 20170504_23:23
plamo 5.x i386 default 20170429_21:36
plamo 6.x amd64 default 20170504_22:05
plamo 6.x i386 default 20170504_22:05
ubuntu artful amd64 default 20170504_03:49
ubuntu artful arm64 default 20170505_08:26
ubuntu artful armhf default 20170504_03:49
ubuntu artful i386 default 20170504_03:49
ubuntu artful ppc64el default 20170430_03:49
ubuntu artful s390x default 20170504_03:49
ubuntu precise amd64 default 20170504_03:49
ubuntu precise armel default 20170504_03:49
ubuntu precise armhf default 20170504_03:49
ubuntu precise i386 default 20170504_03:49
ubuntu precise powerpc default 20170505_03:49
ubuntu trusty amd64 default 20170504_03:49
ubuntu trusty arm64 default 20170505_10:25
ubuntu trusty armhf default 20170504_03:49
ubuntu trusty i386 default 20170504_03:49
ubuntu trusty powerpc default 20170505_03:49
ubuntu trusty ppc64el default 20170429_10:37
ubuntu xenial amd64 default 20170504_03:49
ubuntu xenial arm64 default 20170504_03:49
ubuntu xenial armhf default 20170504_03:49
ubuntu xenial i386 default 20170504_03:49
ubuntu xenial powerpc default 20170504_03:49
ubuntu xenial ppc64el default 20170430_03:49
ubuntu xenial s390x default 20170505_08:26
ubuntu yakkety amd64 default 20170504_03:49
ubuntu yakkety arm64 default 20170505_10:25
ubuntu yakkety armhf default 20170504_03:49
ubuntu yakkety i386 default 20170504_03:49
ubuntu yakkety powerpc default 20170505_03:49
ubuntu yakkety ppc64el default 20170430_03:49
ubuntu yakkety s390x default 20170505_08:26
ubuntu zesty amd64 default 20170504_03:49
ubuntu zesty arm64 default 20170504_03:49
ubuntu zesty armhf default 20170504_03:49
ubuntu zesty i386 default 20170504_03:49
ubuntu zesty powerpc default 20170317_03:49
ubuntu zesty ppc64el default 20170430_03:49
ubuntu zesty s390x default 20170504_03:49
---

Distribution: debian
Release: wheezy
Architecture: amd64

Downloading the image index
Downloading the rootfs
Downloading the metadata
The image cache is now ready
Unpacking the rootfs

---
You just created a Debian container (release=wheezy, arch=amd64, variant=default)

To enable sshd, run: apt-get install openssh-server

For security reason, container images ship without user accounts
and without a root password.

Use lxc-attach or chroot directly into the rootfs to set a root password
or create user accounts.

然後真的要像說明一樣,chroot 過去,設定 root 的 password:
sudo chroot /var/lib/lxc/download/rootfs
在 chroot 後用 passwd 改 root password。
然後要apt-get install vi,然後就會發現找不到 http://httpredir.debian.org
這是因為 dns 錯的關係,因為沒有vi,只好手動..
rm /etc/resolv.conf
echo 10.244.128.5 >> /etc/resolv.conf
之後就可以用 apt-get 了。
chroot 之後用 apt-get install vim
也可順便install iputils-ping

之後就可以用 lxc-start 啟動,login..

host 的 network setup 就像上一篇一樣,用 lxcbr0 static ip.
所以 /var/lib/lxc/download/config 的內容就跟上次一樣 ...
# Template used to create this container: /usr/share/lxc/templates/lxc-download
# Parameters passed to the template:
# For additional config options, please look at lxc.container.conf(5)

# Distribution configuration
lxc.include = /usr/share/lxc/config/debian.common.conf
lxc.arch = x86_64

# Container specific configuration
lxc.rootfs = /var/lib/lxc/download/rootfs
lxc.utsname = download

# Network configuration
lxc.network.type = veth
lxc.network.link = lxcbr0
lxc.network.flags = up
第一次啟動,因為 /etc/network/interfaces 的內容還是 dhcp,所以會等一下,timeout 後,登入 root, 再修改 /etc/network/interfaces..
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 10.10.20.10
netmask 255.255.255.0
gateway 10.10.20.1
dns-nameservers 10.244.128.5 10.244.128.6
重新啟動後,網路就正常了..

沒有留言:

張貼留言