You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
2.5 KiB
Markdown

4 years ago
# Portainer in docker
4 years ago
###### guide-by-example
4 years ago
4 years ago
![logo](https://i.imgur.com/QxnuB1g.png)
4 years ago
4 years ago
# Purpose
4 years ago
4 years ago
Web UI for overview and management of docker environment.
4 years ago
* [Official site](https://www.portainer.io)
* [Github](https://github.com/portainer/portainer)
* [DockerHub image used](https://hub.docker.com/r/portainer/portainer/)
Portainer is a lightweight management web UI, that allows to easily manage
4 years ago
docker containers, networks, volumes, images,... the work.
4 years ago
In my use it is mostly information tool, rather than a management tool.
4 years ago
4 years ago
# Files and directory structure
```
4 years ago
/home/
└── ~/
└── docker/
└── portainer/
4 years ago
├── portainer-data/
4 years ago
├── .env
└── docker-compose.yml
4 years ago
```
4 years ago
* `portainer-data/` - a directory where portainer stores its peristent data
4 years ago
* `.env` - a file containing environment variables for docker compose
4 years ago
* `docker-compose.yml` - a docker compose file, telling docker
4 years ago
how to run the containers
4 years ago
You only need to provide the files.</br>
The directory is created by docker compose on the first run.
4 years ago
# docker-compose
`docker-compose.yml`
```yml
version: '2'
services:
portainer:
image: portainer/portainer
container_name: portainer
hostname: portainer
command: -H unix:///var/run/docker.sock
restart: unless-stopped
4 years ago
env_file: .env
4 years ago
volumes:
- /var/run/docker.sock:/var/run/docker.sock
4 years ago
- ./portainer-data:/data
4 years ago
networks:
default:
external:
4 years ago
name: $DOCKER_MY_NETWORK
4 years ago
```
`.env`
```bash
# GENERAL
4 years ago
MY_DOMAIN=example.com
4 years ago
DOCKER_MY_NETWORK=caddy_net
4 years ago
TZ=Europe/Bratislava
4 years ago
```
# reverse proxy
4 years ago
Caddy v2 is used, details
[here](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/caddy_v2).</br>
4 years ago
`Caddyfile`
```
portainer.{$MY_DOMAIN} {
reverse_proxy portainer:9000
}
```
# Update
4 years ago
[Watchtower](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/watchtower)
updates the image automatically.
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
4 years ago
4 years ago
* 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`