meta data for this page
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| vm:proxmox:lxc [2020/05/08 08:01] – niziak | vm:proxmox:lxc [2021/02/22 08:18] (current) – niziak | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== LXC ====== | ====== LXC ====== | ||
| + | ===== rename CT ===== | ||
| + | <code bash>pct set < | ||
| - | ===== docker inside unprivileged LXC ===== | + | ===== update CT templates |
| - | + | ||
| - | Some hints: | + | |
| - | * Docker is recommended to be used inside VM. | + | |
| - | * '' | + | |
| - | * In priviledged container it works with '' | + | |
| - | * From [[https:// | + | |
| - | * ZFS over ZFS is not possible (ZFS nesting) | + | |
| - | + | ||
| - | From documentation: | + | |
| - | + | ||
| - | * edit LXC container config <file | / | + | |
| - | features: | + | |
| - | </ | + | |
| - | * stop/start LXC container <code bash> | + | |
| - | + | ||
| - | ==== VFS FS is used by docker. ==== | + | |
| - | + | ||
| - | + | ||
| - | The vfs backend is a very simple fallback that has no copy-on-write support. Each layer is just a separate directory. Creating a new layer based on another layer is done by making a deep copy of the base layer into a new directory. | + | |
| - | Since this backend doesn’t share diskspace use between layers, and since creating a new layer is a slow operation this is not a very practical backend. However, it still has its uses, for instance to verify other backends against, or if you need a super robust (if slow) backend that works everywhere. | + | |
| - | | + | |
| <code bash> | <code bash> | ||
| - | docker info | + | # pveam - Proxmox VE Appliance Manager |
| - | ... | + | pveam update |
| - | | + | |
| - | | + | |
| - | ... | + | |
| </ | </ | ||
| - | When restarted in privileged container: | ||
| - | NOTE: restarting in privileged container do mess with user permission. Make backup/ | ||
| - | <code bash> | + | ===== Shrink container disc ===== |
| - | docker info | + | |
| - | ... | + | |
| - | | + | |
| - | Root Dir: / | + | |
| - | Backing Filesystem: zfs | + | |
| - | Dirs: 0 | + | |
| - | Dirperm1 Supported: true | + | |
| - | ... | + | |
| - | </ | + | |
| + | It is not supported. Command <code bash>pct resize < | ||
| - | ==== Use RAW image for Docker ==== | + | Workaround 1: |
| + | * Stop container | ||
| + | * Edit ''< | ||
| + | * Perform backup | ||
| + | * Restore LXC from backup | ||
| - | Edit existing '' | + | Workaround 2: |
| - | * '' | + | * Change ZFS volume size <code bash>zfs set refquota=8G rpool/ |
| - | * '' | + | * Adjust LXC config: |
| + | * Edit '' | ||
| + | * '' | ||
| - | Add mount point to LXC: | ||
| - | * Resources --> Add --> Mount Point | ||
| - | * Storage: '' | ||
| - | * Backup: NO | ||
| - | * Path: ''/ | ||
| - | * Mount options: '' | ||
| - | |||
| - | And new RAW disc will be created, with EXT4 FS. | ||
| - | Docker will use '' | ||
| - | |||
| - | ==== Bind mount host btrfs subvolume ==== | ||
| - | |||
| - | * Only directory hierarchy under ''/ | ||
| - | * Host permission and ACL will be used. To play with permission to shared folder please read: [[https:// | ||
| - | * [[https:// | ||
| - | * CONS: no disk size control inside guest. Possible to use btrfs subvolume quotas | ||
| - | |||
| - | Login to host using SSH node | ||
| - | |||
| - | <code bash> | ||
| - | btrfs subvol create / | ||
| - | btrfs quota enable / | ||
| - | btrfs subvol create / | ||
| - | btrfs qgroup limit 50G / | ||
| - | |||
| - | # Disable COW for performance: | ||
| - | chattr +C -f -R / | ||
| - | |||
| - | # Give unprivilged container right to write | ||
| - | chown 100000.100000 / | ||
| - | # setfacl -Rm user: | ||
| - | |||
| - | pct set <cid> -mp0 / | ||
| - | </ | ||
| - | |||
| - | <code bash> | ||
| - | btrfs quota rescan / | ||
| - | btrfs qgroup show -pcre | ||
| - | </ | ||
| - | |||
| - | |||
| - | ==== Enabling ZFS tools and access - no success ==== | ||
| - | |||
| - | <code bash> | ||
| - | dockerd -D --storage-driver zfs | ||
| - | ... | ||
| - | zfs command is not available: exec: " | ||
| - | ... | ||
| - | apt-get install zfsutils-linux | ||
| - | |||
| - | dockerd -D --storage-driver zfs | ||
| - | ... | ||
| - | DEBU[2020-05-06T16: | ||
| - | ... | ||
| - | </ | ||
| - | |||
| - | <file | / | ||
| - | lxc.mount.entry: | ||
| - | </ | ||
| - | Exposing ''/ | ||
| - | After this trick, Docker starts and detects ZFS without any additional configuration. | ||
| - | But usage is not possible. Docker cannot create additional subvolumes | ||
| - | |||
| - | <code bash> | ||
| - | ~# docker run hello-world | ||
| - | Unable to find image ' | ||
| - | latest: Pulling from library/ | ||
| - | 0e03bdcc26d7: | ||
| - | docker: failed to register layer: exit status 1: "/ | ||
| - | </ | ||
| - | |||
| - | Try to add permission on host (note, not possible to use UID which not exists in / | ||
| - | <code bash> | ||
| - | zfs allow -u 100000 create, | ||
| - | </ | ||
| - | |||
| - | Doesn' | ||
| - | |||
| - | |||
| - | |||
| - | ==== Trying to run on ZFS - without success ==== | ||
| - | |||
| - | Solution: | ||
| - | <code bash> | ||
| - | cp / | ||
| - | </ | ||
| - | |||
| - | Edit new file and update '' | ||
| - | |||
| - | < | ||
| - | # Do not load this file. Rather, load / | ||
| - | # will source all profiles under / | ||
| - | |||
| - | profile lxc-container-default-with-nesting-docker flags=(attach_disconnected, | ||
| - | #include < | ||
| - | #include < | ||
| - | |||
| - | deny / | ||
| - | deny / | ||
| - | mount fstype=proc -> / | ||
| - | mount fstype=sysfs -> / | ||
| - | mount options=(rw, | ||
| - | mount fstype=cgroup -> / | ||
| - | mount fstype=cgroup2 -> / | ||
| - | mount fstype=aufs, | ||
| - | mount fstype=overlay, | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | <code bash> | ||
| - | |||
| - | Edit ''/ | ||
| - | <file | / | ||
| - | lxc.apparmor.profile: | ||
| - | </ | ||
| - | |||
| - | === Disabling apparmor === | ||
| - | |||
| - | <file | / | ||
| - | lxc.apparmor.profile = unconfined | ||
| - | </ | ||
| - | |||
| - | <code bash> | ||
| - | |||
| - | |||
| - | |||
| - | === Forcing '' | ||
| - | |||
| - | Error: AUFS cannot be used in non-init user namespace | ||
| - | |||
| - | === Forcing '' | ||
| - | |||
| - | On host log: | ||
| - | < | ||
| - | kernel: overlayfs: filesystem on '/ | ||
| - | kernel: overlayfs: filesystem on '/ | ||
| - | </ | ||
| - | There are some requirements to use overlayfs. It is not possible to use it over '' | ||