Compare commits

..

6 Commits

Author SHA1 Message Date
6aeb5ca655 revision 2023-09-28 21:40:34 +01:00
20ff1390dd refactoring 2022-12-13 00:53:15 +00:00
7d2beca0ca info 2022-12-13 00:12:20 +00:00
0dbb1ed83f . 2022-12-12 23:47:51 +00:00
6b93bc4400 testing 2022-12-12 23:28:57 +00:00
6a2e10ea7b testing 2022-12-12 23:28:22 +00:00
3 changed files with 163 additions and 148 deletions

248
README.md
View File

@@ -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/

View File

@@ -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)

View File

@@ -1,15 +1,22 @@
#!/bin/bash #!/bin/bash
#start container LXC_CONTAINER_NAME=$1
lxc launch ubuntu $1 -p $2 LXC_PROFILE=$2
#set docker requirements echo "container name: $LXC_CONTAINER_NAME"
curl -s "https://git.limbosolutions.com/kb/lxc/raw/branch/main/scripts/lxc-config-docker-requirements.sh" | bash -s $1 echo "profile: $LXC_PROFILE"
lxc restart $1
lxc exec $1 -s "apt update -y && apt upgrade -y"
#setup docker echo "starting container"
lxc exec $1 bash -s "curl -s \"https://git.limbosolutions.com/kb/docker/raw/branch/main/scripts/ubuntu-fuse-setup.sh\" | bash" lxc launch ubuntu $LXC_CONTAINER_NAME -p $LXC_PROFILE
#portainer echo "setting lxc docker requirements"
lxc exec $1 bash -s "curl -s \"https://git.limbosolutions.com/kb/portainer/raw/branch/main/scripts/setup.sh\" | bash" curl -s "https://git.limbosolutions.com/kb/lxc/raw/branch/main/scripts/lxc-config-docker-requirements.sh" | bash -s $LXC_CONTAINER_NAME
lxc restart $LXC_CONTAINER_NAME
echo "updating apt"
lxc exec $LXC_CONTAINER_NAME -- sh -c "apt-get update -qq >/dev/null"
echo "upgrading apt"
lxc exec $LXC_CONTAINER_NAME -- sh -c "apt-get upgrade -qq >/dev/null"
echo "installing fuse & docker"
lxc exec $LXC_CONTAINER_NAME -- bash -c "curl -s \"https://git.limbosolutions.com/kb/docker/raw/branch/main/scripts/ubuntu-fuse-setup.sh\" | bash"
echo "installing portainer"
lxc exec $LXC_CONTAINER_NAME -- bash -c "curl -s \"https://git.limbosolutions.com/kb/portainer/raw/branch/main/scripts/setup.sh\" | bash"