Files
vps-docs/09-docker.md
2026-04-08 16:15:11 +02:00

103 lines
2.5 KiB
Markdown

# 9. Docker
## Installation
Si Docker n'est pas deja installe :
```bash
apt-get update
apt-get install ca-certificates curl
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
```
Verifier :
```bash
docker run hello-world
```
## Docker Swarm
```bash
docker swarm init
docker node ls
```
## Portainer
1. DNS A `portainer` -> `<IP>`
2. Sous-domaine ISPConfig `portainer.<DOMAINE>` avec proxy :
```apache
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyRequests Off
ProxyPass /stats !
ProxyPass /.well-known/acme-challenge !
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
ProxyPreserveHost On
ProxyPass / http://localhost:9050/
ProxyPassReverse / http://localhost:9050/
RedirectMatch ^/$ https://portainer.<DOMAINE>
```
3. Installer :
```bash
docker volume create portainer_data
docker run -d -p 9050:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
```
4. Acceder : `https://portainer.<DOMAINE>` — creer le compte admin.
## Yacht
1. DNS A `yacht` -> `<IP>`
2. Sous-domaine ISPConfig avec proxy vers `http://localhost:8061/`
3. Installer :
```bash
docker volume create yacht_data
docker run -d -p 8061:8000 --name=yacht -v /var/run/docker.sock:/var/run/docker.sock --restart=always -v yacht_data:/config selfhostedpro/yacht
```
4. Login par defaut : `admin@yacht.local` / `pass` — changer immediatement.
## Modele Apache Directives pour proxy Docker
Pour tous les services Docker accessibles via sous-domaine :
```apache
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyRequests Off
ProxyPass /stats !
ProxyPass /.well-known/acme-challenge !
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
ProxyPreserveHost On
ProxyPass / http://localhost:<PORT>/
ProxyPassReverse / http://localhost:<PORT>/
RedirectMatch ^/$ https://<SOUS_DOMAINE>.<DOMAINE>
```
> **Piege :** Apres creation du sous-domaine, supprimer le fichier `standard_index.html` si la page par defaut ISPConfig s'affiche. Aussi verifier que SSL/Let's Encrypt est bien coche.