lxc:install_lxc
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
lxc:install_lxc [2021/01/03 16:36] – peter | lxc:install_lxc [2021/01/07 20:13] (current) – peter | ||
---|---|---|---|
Line 8: | Line 8: | ||
<code bash> | <code bash> | ||
- | sudo apt install lxc | + | sudo apt install lxc |
</ | </ | ||
Line 20: | Line 20: | ||
<code bash> | <code bash> | ||
- | sudo apt install lxc-utils | + | sudo apt install lxc-utils |
</ | </ | ||
Line 72: | Line 72: | ||
---- | ---- | ||
+ | ===== Create ~/ | ||
+ | |||
+ | <code bash> | ||
+ | mkdir ~/ | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Create ~/ | ||
+ | |||
+ | <file bash ~/ | ||
+ | lxc.include = / | ||
+ | lxc.idmap = u 0 100000 65536 | ||
+ | lxc.idmap = g 0 100000 65536 | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Test ===== | ||
+ | |||
+ | <code bash> | ||
+ | lxc-create -t download -n test | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | </ | ||
+ | |||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | |||
+ | <code bash> | ||
+ | Setting up the GPG keyring | ||
+ | ERROR: Unable to fetch GPG key from keyserver | ||
+ | lxc-create: test: lxccontainer.c: | ||
+ | lxc-create: test: tools/ | ||
+ | </ | ||
+ | |||
+ | Try using the following: | ||
+ | |||
+ | <code bash> | ||
+ | lxc-create -t download -n test -- --keyserver hkp:// | ||
+ | </ | ||
+ | |||
+ | or | ||
+ | |||
+ | <code bash> | ||
+ | lxc-create -n test -t download -- --no-validate | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | <code bash> | ||
+ | Setting up the GPG keyring | ||
+ | Downloading the image index | ||
+ | |||
+ | --- | ||
+ | DIST RELEASE ARCH VARIANT BUILD | ||
+ | --- | ||
+ | alpine 3.10 amd64 default 20210103_13: | ||
+ | alpine 3.10 arm64 default 20210103_13: | ||
+ | alpine 3.10 armhf default 20210103_13: | ||
+ | alpine 3.10 i386 default 20210103_13: | ||
+ | ... | ||
+ | centos 8 amd64 default 20210103_07: | ||
+ | centos 8 arm64 default 20210103_07: | ||
+ | centos 8 ppc64el default 20210103_07: | ||
+ | debian bullseye amd64 default 20210103_05: | ||
+ | debian bullseye arm64 default 20210103_05: | ||
+ | ... | ||
+ | ubuntu trusty arm64 default 20210103_07: | ||
+ | ubuntu trusty armhf default 20210103_07: | ||
+ | ubuntu trusty i386 default 20210103_07: | ||
+ | ubuntu trusty ppc64el default 20210103_07: | ||
+ | ubuntu xenial amd64 default 20210103_07: | ||
+ | ubuntu xenial arm64 default 20210103_07: | ||
+ | ubuntu xenial armhf default 20210103_07: | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== Select which image to use ==== | ||
+ | |||
+ | In this example the following is chosen: | ||
+ | |||
+ | * Distribution: | ||
+ | * Release: | ||
+ | * Architecture: | ||
+ | |||
+ | |||
+ | <code bash> | ||
+ | Distribution: | ||
+ | ubuntu | ||
+ | Release: | ||
+ | xenial | ||
+ | Architecture: | ||
+ | amd64 | ||
+ | |||
+ | Downloading the image index | ||
+ | Downloading the rootfs | ||
+ | Downloading the metadata | ||
+ | The image cache is now ready | ||
+ | Unpacking the rootfs | ||
+ | |||
+ | --- | ||
+ | |||
+ | You just created an Ubuntu xenial amd64 (20210103_07: | ||
+ | |||
+ | To enable SSH, run: apt install openssh-server | ||
+ | No default root or user password are set by LXC. | ||
+ | </ | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== Check the container status ==== | ||
+ | |||
+ | <code bash> | ||
+ | lxc-info -n test | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | <code bash> | ||
+ | Name: test | ||
+ | State: | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== Start the Container ==== | ||
+ | |||
+ | <code bash> | ||
+ | lxc-start -n test | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | |||
+ | <code bash> | ||
+ | lxc-start: test: lxccontainer.c: | ||
+ | lxc-start: test: tools/ | ||
+ | lxc-start: test: tools/ | ||
+ | lxc-start: test: tools/ | ||
+ | </ | ||
+ | |||
+ | By default, unprivileged users are not allowed to create any network device on the host. To fix: | ||
+ | |||
+ | <file bash / | ||
+ | peter veth lxcbr0 10 | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | </ | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== Check the container status again ==== | ||
+ | |||
+ | <code bash> | ||
+ | lxc-info -n test | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | <code bash> | ||
+ | Name: test | ||
+ | State: | ||
+ | PID: 793414 | ||
+ | IP: | ||
+ | Link: | ||
+ | TX bytes: | ||
+ | RX bytes: | ||
+ | Total bytes: | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== Get a Shell inside the Container ==== | ||
+ | |||
+ | <code bash> | ||
+ | lxc-attach -n test | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | </ | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== Stop the Test Container ==== | ||
+ | |||
+ | <code bash> | ||
+ | lxc-stop -n test | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== Remove the Test Container ==== | ||
+ | |||
+ | <code bash> | ||
+ | lxc-destroy -n test | ||
+ | </ | ||
+ | |||
+ | ---- | ||
===== References ===== | ===== References ===== |
lxc/install_lxc.1609691764.txt.gz · Last modified: 2021/01/03 16:36 by peter