revision
This commit is contained in:
248
README.md
248
README.md
@@ -1,120 +1,128 @@
|
|||||||
# lxc
|
# lxc
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
requires snap
|
requires snap
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo apt install snap
|
sudo apt install snap
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo snap install lxd
|
sudo snap install lxd
|
||||||
sudo usermod -a -G lxd $(whoami)
|
sudo usermod -a -G lxd $(whoami)
|
||||||
```
|
```
|
||||||
|
|
||||||
Init
|
Init
|
||||||
|
|
||||||
Setup lxd
|
Setup lxd
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo lxd init
|
sudo lxd init
|
||||||
```
|
```
|
||||||
|
|
||||||
## Containers
|
## Containers
|
||||||
|
|
||||||
### List
|
### List
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
lxc list
|
lxc list
|
||||||
```
|
```
|
||||||
|
|
||||||
### Get Info
|
### Get Info
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
lxc info containername
|
lxc info containername
|
||||||
```
|
```
|
||||||
|
|
||||||
### Create
|
### Create
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
lxc launch ubuntu containername
|
lxc launch ubuntu containername
|
||||||
```
|
```
|
||||||
|
|
||||||
### move
|
### move
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
lxc mv ubuntu ubuntu1
|
lxc mv ubuntu ubuntu1
|
||||||
lxc mv ubuntu1 -s=poolname
|
lxc mv ubuntu1 -s=poolname
|
||||||
```
|
```
|
||||||
|
|
||||||
### Stop
|
### Stop
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
lxc stop containername
|
lxc stop containername
|
||||||
```
|
```
|
||||||
|
|
||||||
Exec bash on container
|
Exec bash on container
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
lxc exec $containername bash
|
lxc exec $containername bash
|
||||||
```
|
```
|
||||||
|
|
||||||
### Exec multiple commands
|
### Exec multiple commands
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
lxc exec "container name" -- bash -c "apt update -y && apt upgrade -y"
|
lxc exec "container name" -- bash -c "apt update -y && apt upgrade -y"
|
||||||
```
|
```
|
||||||
|
|
||||||
### delete a container
|
### delete a container
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
lxc rm "container name"
|
lxc rm "container name"
|
||||||
#if force required
|
#if force required
|
||||||
lxc rm "container name" --force
|
lxc rm "container name" --force
|
||||||
```
|
```
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
|
|
||||||
Edit
|
Edit
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
lxc config edit "container name"
|
lxc config edit "container name"
|
||||||
```
|
```
|
||||||
|
|
||||||
Set value
|
Set value
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
#Example
|
#Example
|
||||||
lxc config set "container name" "security.nesting" "true"
|
lxc config set "container name" "security.nesting" "true"
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Profile Management
|
### Profile Management
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
lxc profile remove "container name" "profile name to remote"
|
lxc profile remove "container name" "profile name to remote"
|
||||||
lxc profile assign "container name" "profile name to assign"
|
lxc profile assign "container name" "profile name to assign"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Profiles
|
## Profiles
|
||||||
|
|
||||||
### macvlan only
|
### macvlan only
|
||||||
|
|
||||||
1) create copy from default
|
1) create copy from default
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
lxc profile copy default eth0_macvlan
|
lxc profile copy default eth0_macvlan
|
||||||
lxc profile edit eth0_macvlan
|
lxc profile edit eth0_macvlan
|
||||||
```
|
```
|
||||||
|
|
||||||
1) edit new profile
|
1) edit new profile
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
||||||
devices:
|
devices:
|
||||||
eth0:
|
eth0:
|
||||||
nictype: macvlan
|
nictype: macvlan
|
||||||
parent: eth0 # parent ethernet name
|
parent: eth0 # parent ethernet name
|
||||||
type: nic
|
type: nic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## swap
|
||||||
|
|
||||||
|
swap on lxc
|
||||||
|
limits.memory.swap: "false"
|
||||||
|
|
||||||
|
swap on host
|
||||||
|
https://www.shellhacks.com/swappiness-in-linux-ubuntu-how-to-change/
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
# Running Docker
|
# Running Docker
|
||||||
|
|
||||||
on a lxc container
|
on a lxc container
|
||||||
|
|
||||||
## setup lxc container for docker
|
## setup lxc container for docker
|
||||||
|
|
||||||
### Config
|
### Config
|
||||||
|
|
||||||
- security.nesting: "true"
|
- security.nesting: "true"
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
lxc config set $CONTAINER_NAME "security.nesting" "true"
|
lxc config set $CONTAINER_NAME "security.nesting" "true"
|
||||||
#/scripts/lxc-config-docker-requirements.sh $CONTAINER_NAME
|
#/scripts/lxc-config-docker-requirements.sh $CONTAINER_NAME
|
||||||
```
|
```
|
||||||
|
|
||||||
### setup ubuntu container
|
### setup ubuntu container
|
||||||
|
|
||||||
Install docker with fuse fs [more information] (/kb/docker)
|
Install docker with fuse fs [more information] (/kb/docker)
|
||||||
|
|||||||
Reference in New Issue
Block a user