Skip to content

Instantly share code, notes, and snippets.

@kentarosasaki
Last active September 12, 2017 03:56
Show Gist options
  • Save kentarosasaki/ad680d98a2155bbe1a09 to your computer and use it in GitHub Desktop.
Save kentarosasaki/ad680d98a2155bbe1a09 to your computer and use it in GitHub Desktop.
Docker だけじゃない Containers の世界 ref: http://qiita.com/kentarosasaki/items/b44b5ffb57a69085027e
$ sudo apt-get install lxc
$ ls /usr/share/lxc/templates/
lxc-alpine lxc-archlinux lxc-centos lxc-debian lxc-fedora lxc-openmandriva lxc-oracle lxc-sshd lxc-ubuntu-cloud
lxc-altlinux lxc-busybox lxc-cirros lxc-download lxc-gentoo lxc-opensuse lxc-plamo lxc-ubuntu
$ sudo lxc-info -n test-container-101
Name: test-container-101
State: STOPPED
$ sudo lxc-info -n test-container-101
Name: test-container-101
State: RUNNING
PID: 20434
CPU use: 0.77 seconds
BlkIO use: 7.16 MiB
Memory use: 13.53 MiB
KMem use: 0 bytes
Link: vethABI04E
TX bytes: 940 bytes
RX bytes: 592 bytes
Total bytes: 1.50 KiB
$ sudo lxc-info -n test-container-101 -c lxc.utsname -c lxc.rootfs
lxc.utsname = test-container-101
lxc.rootfs = /var/lib/lxc/test-container-101/rootfs
$ sudo add-apt-repository ppa:ubuntu-lxc/lxd-git-master
$ sudo apt-get update && sudo apt-get -y install lxd
$ sudo lxd-images import lxc ubuntu trusty amd64 --alias ubuntu
$ sudo lxc image list
+--------+--------------+--------+-------------+--------+------------------------------+
| ALIAS | FINGERPRINT | PUBLIC | DESCRIPTION | ARCH | UPLOAD DATE |
+--------+--------------+--------+-------------+--------+------------------------------+
| ubuntu | 04aac4257341 | no | | x86_64 | Jul 15, 2015 at 1:16pm (UTC) |
+--------+--------------+--------+-------------+--------+------------------------------+
$ sudo lxc launch ubuntu test-container-102
Creating container...done
Starting container...done
error: saving config file for the container failed
$ lxc list
+--------------------+---------+------------+------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | EPHEMERAL | SNAPSHOTS |
+--------------------+---------+------------+------+-----------+-----------+
| test-container-103 | RUNNING | 10.0.3.138 | | NO | 0 |
+--------------------+---------+------------+------+-----------+-----------+
$ sudo lxc-create -t ubuntu -n test-container-101
/var/lib/lxc/<コンテナ名>/
$ sudo ls -F /var/lib/lxc/test-container-101/rootfs/
bin/ boot/ dev/ etc/ home/ lib/ lib64/ media/ mnt/
opt/ proc/ root/ run/ sbin/ srv/ sys/ tmp/ usr/ var/
$ sudo lxc-start -n test-container-101 -d
$ sudo lxc-console -n test-container-101
# The default user is 'ubuntu' with password 'ubuntu'!
# Use the 'sudo' command to run tasks as root in the container.
$ sudo lxc-shutdown -n test-container-101
$ sudo lxc-ls --fancy
NAME STATE IPV4 IPV6 AUTOSTART
--------------------------------------------------
test-container-101 STOPPED - - NO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment