selfhosted-apps-docker/portainer/readme.md

110 lines
2.5 KiB
Markdown
Raw Normal View History

2020-04-09 22:52:11 +00:00
# Portainer in docker
2020-05-18 22:49:18 +00:00
###### guide-by-example
2020-04-09 22:52:11 +00:00
2020-04-25 23:48:23 +00:00
![logo](https://i.imgur.com/QxnuB1g.png)
2020-04-09 22:52:11 +00:00
2020-04-25 23:48:23 +00:00
# Purpose
2020-04-09 22:52:11 +00:00
2023-03-31 22:12:41 +00:00
Web GUI for overview and management of docker environment.
2020-05-10 13:32:38 +00:00
* [Official site](https://www.portainer.io)
* [Github](https://github.com/portainer/portainer)
2021-02-22 22:25:12 +00:00
* [DockerHub image used](https://hub.docker.com/r/portainer/portainer-ce/)
2020-05-10 13:32:38 +00:00
2023-03-31 22:43:34 +00:00
Lightweight, allows to easily manage docker containers,
images, networks, volumes,...
2020-05-10 13:32:38 +00:00
2023-03-31 22:43:34 +00:00
I don't really use as I love [ctop])(https://github.com/bcicen/ctop),
but I keep eye out on it and recommend it to noobs.
2020-04-09 22:52:11 +00:00
2020-04-25 23:48:23 +00:00
# Files and directory structure
```
2020-05-01 09:38:43 +00:00
/home/
└── ~/
└── docker/
└── portainer/
2023-03-31 22:12:41 +00:00
├── portainer_data/
2020-05-01 09:38:43 +00:00
├── .env
└── docker-compose.yml
2020-04-25 23:48:23 +00:00
```
2023-03-31 22:12:41 +00:00
* `portainer_data/` - a directory where portainer stores its peristent data
2020-05-22 16:05:03 +00:00
* `.env` - a file containing environment variables for docker compose
2020-05-10 13:32:38 +00:00
* `docker-compose.yml` - a docker compose file, telling docker
2020-05-22 16:22:45 +00:00
how to run the containers
2020-05-10 13:32:38 +00:00
You only need to provide the files.</br>
The directory is created by docker compose on the first run.
2020-04-25 23:48:23 +00:00
# docker-compose
`docker-compose.yml`
```yml
services:
portainer:
2021-02-22 22:25:12 +00:00
image: portainer/portainer-ce
2020-04-25 23:48:23 +00:00
container_name: portainer
hostname: portainer
command: -H unix:///var/run/docker.sock
restart: unless-stopped
2020-04-26 00:43:30 +00:00
env_file: .env
2020-04-25 23:48:23 +00:00
volumes:
- /var/run/docker.sock:/var/run/docker.sock
2023-03-31 22:12:41 +00:00
- ./portainer_data:/data
expose:
- "9443"
2020-04-25 23:48:23 +00:00
networks:
default:
2023-03-31 22:12:41 +00:00
name: $DOCKER_MY_NETWORK
external: true
2020-04-25 23:48:23 +00:00
```
`.env`
```bash
# GENERAL
2020-05-20 18:29:12 +00:00
DOCKER_MY_NETWORK=caddy_net
2020-05-02 20:48:23 +00:00
TZ=Europe/Bratislava
2020-04-25 23:48:23 +00:00
```
# reverse proxy
2020-05-01 09:51:20 +00:00
Caddy v2 is used, details
[here](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/caddy_v2).</br>
2020-04-25 23:48:23 +00:00
`Caddyfile`
```
2023-03-31 22:12:41 +00:00
port.example.com {
reverse_proxy portainer:9443 {
transport http {
tls
tls_insecure_skip_verify
}
}
2020-04-25 23:48:23 +00:00
}
```
# Update
2020-05-10 13:32:38 +00:00
Manual image update:
- `docker-compose pull`</br>
- `docker-compose up -d`</br>
- `docker image prune`
# Backup and restore
#### Backup
Using [borg](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/borg_backup)
that makes daily snapshot of the entire directory.
#### Restore
2020-04-25 23:48:23 +00:00
2020-05-10 15:06:37 +00:00
* down the portainer container `docker-compose down`</br>
* delete the entire portainer directory</br>
* from the backup copy back the portainer directory</br>
* start the container `docker-compose up -d`