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.

110 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
1 year ago
Web GUI for overview and management of docker environment.
4 years ago
* [Official site](https://www.portainer.io)
* [Github](https://github.com/portainer/portainer)
3 years ago
* [DockerHub image used](https://hub.docker.com/r/portainer/portainer-ce/)
4 years ago
1 year ago
Lightweight, allows to easily manage docker containers,
images, networks, volumes,...
4 years ago
1 year ago
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.
4 years ago
4 years ago
# Files and directory structure
```
4 years ago
/home/
└── ~/
└── docker/
└── portainer/
1 year ago
├── portainer_data/
4 years ago
├── .env
└── docker-compose.yml
4 years ago
```
1 year 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
services:
portainer:
3 years ago
image: portainer/portainer-ce
4 years ago
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
1 year ago
- ./portainer_data:/data
expose:
- "9443"
4 years ago
networks:
default:
1 year ago
name: $DOCKER_MY_NETWORK
external: true
4 years ago
```
`.env`
```bash
# GENERAL
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`
```
1 year ago
port.example.com {
reverse_proxy portainer:9443 {
transport http {
tls
tls_insecure_skip_verify
}
}
4 years ago
}
```
# Update
4 years ago
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`