# Docker

### On compute module :

```bash
mkdir -p /mnt/docker/data
mkdir -p /mnt/docker/compose
```

```
sudo apt update && sudo apt install apt-transport-https ca-certificates curl wget gnupg lsb-release -y

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker.gpg

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt update && sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-compose -y
```

### Version courte :

```
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $(whoami)
newgrp docker
docker run hello-world
```

##### Relocate /var/lib/docker

```bash
#Stop docker
sudo systemctl stop docker.service
sudo systemctl stop docker.socket

#Create new data folder and move data
sudo mkdir /mnt/docker/data

sudo rsync -aP /var/lib/docker/ /mnt/docker/data/

# Edit docker config
sudo vim /etc/docker/daemon.json
```
### (!) Changed /mnt/data/dockerdata to /mnt/docker/data (!)
```bash
{ 
  "data-root": "/mnt/docker/data",
  "log-driver": "local",
  "log-opts": {
    "max-size": "10m",
    "max-file": "3"
  }
}
```

```bash
# Restart docker
sudo systemctl start docker.socket
sudo systemctl start docker.service

# Verify...
sudo systemctl status docker
sudo docker info | grep "Docker Root Dir"

# Delete old data folder
sudo rm -rf /var/lib/docker/
```

Fix docker error loading config file
```bash
sudo chown "$USER":"$USER" /home/"$USER"/.docker -R
sudo chmod g+rwx "/home/$USER/.docker" -R
```
#### Portainer

```bash
docker volume create portainer_data
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ee:latest
```

> **login :** admin  
> **password :** thrive-dwelled-flanked

https://portainer.delmar.bzh/  
https://sandy:9443/  
https://192.168.1.70:9443/

> **Licence key :** 2-6yKcInsUmIXoJ2Ep/Qhklg14PEkpMYuyqoUQS8ST4P840dqep0VQUaVsnTYgVVX3g+/gtpFnH8xYyGmCxyDVHA==

#### Yacht

```
lxc config device add docker proxy8000 proxy connect="tcp:127.0.0.1:8000" listen="tcp:0.0.0.0:8000"

docker volume create yacht

docker run -d --name yacht -p 8000:8000 -v /var/run/docker.sock:/var/run/docker.sock -v yacht:/config selfhostedpro/yacht
```

<span class="keep-md">\[</span> admin@delmar.bzh | thrive-dwelled-flanked <span class="keep-md">\]</span>
