Add stuff from askiiart/pc-configs

This commit is contained in:
askiiart 2023-10-20 11:27:00 -05:00
parent 5d03b0a1ec
commit c7c9080553
Signed by untrusted user who does not match committer: askiiart
GPG key ID: BC3800E55FB54D67
18 changed files with 405 additions and 10 deletions

View file

@ -0,0 +1,26 @@
# Fix APIPA (veth)
## Problem
On Debian 11, when:
1. Using docker containers that use the `host` network mode.
2. `PreferredTechnologies` is set to `ethernet,[...]` in `/etc/connman/main.conf`.
- This may not be a problem when ethernet is plugged in, not just wifi.
The system **uses a veth interface** to connect to the internet, which uses an APIPA (169.254.*.*) IP address, so the system can only contact devices on the LAN.
## Solution
Edit `/etc/connman/main.conf` and uncomment the line `# NetworkInterfaceBlacklist = vmnet,vboxnet,virbr,ifb,ve-,vb-`
Result:
```conf
NetworkInterfaceBlacklist = vmnet,vboxnet,virbr,ifb,ve-,vb-
```
## References
- [A tale of Docker and Linux ConnMan](https://sitaram.substack.com/p/a-tale-of-docker-and-linux-connman)
- [Arch Linux Docs](https://wiki.archlinux.org/title/ConnMan#Blacklist_interfaces)

View file

@ -0,0 +1,24 @@
# Move Docker program data
Docker stores all its data in `/var/lib/docker` by default. This is usually fine, but this directory grows quickly, so we'll move it to `/mnt/big-stuff/docker-program-data/`
Edit `/lib/systemd/system/docker.service` and add the `--data-root` option to the ExecStart line:
```sh
ExecStart=/usr/bin/dockerd --data-root /mnt/big-stuff/docker-program-data/ -H fd:// $DOCKER_OPTS
```
If you've already done stuff with docker, you'll need to move the data:
```sh
sudo systemctl stop docker
sudo mv /var/lib/docker/ /mnt/big-stuff/docker-program-data/
sudo systemctl daemon-reload
sudo systemctl start docker
```
You may also need to set up some symlinks:
```bash
ln -s source_file link_file
```

View file

@ -0,0 +1,44 @@
# Resource limits
You can limit the amount of CPU and/or memory resources that a container can use.
## CPU
| Option | Description |
|--------|-------------|
| `--cpus` | Set number of CPUs thee container can use |
| `--cpu-period` | Limits the length of time it can schedule the CPU before being throttled (used alongside `--cpu-quota`) |
| `--cpu-quota` | The throttling setting activated when the CPU is scheduled longer than `--cpu-period` |
| `--cpuset-cpus` | Limit the container to specific CPUs or cores (e.g. 0-3, 0,1) |
| `--cpu-shares` | The number of relative shares of the CPU the container can use (default 1024) |
## Memory
A markdown table:
| Option | Description |
|--------|-------------|
| `-m` or `--memory` | Memory limit (minimum 6m (megabytes)) |
| `--memory-swap` | How much swap is available - [details](https://docs.docker.com/config/containers/resource_constraints/#--memory-swap-details) |
| `--memory-swappiness` | "By default, the host kernel can swap out a percentage of anonymous pages used by a container. You can set --memory-swappiness to a value between 0 and 100, to tune this percentage" - [details]() |
| `--memory-reservation` | Soft limit less than `--memory` (for when there is low memory on host), *soft* limit, so usage may exceed this. |
| `--oom-kill-disable` | Disable OOM Killer (stops from killing container processes when out-of-memory error occurs) - Make sure to use `-m`, or host processes could be killed |
## Example
Note: `--xxxx 4` in `docker run` would be replaced with `xxxx` in `docker-compose.yml`. See below:
```yml
service:
image: nginx
mem_limit: 512m
mem_reservation: 128M
cpus: 0.5
ports:
- "80:80"
```
## See also
- [Docker documentation](https://docs.docker.com/config/containers/resource_constraints/)
- [Baeldung docs](https://www.baeldung.com/ops/docker-memory-limit) (includes `docker compose` examples)

View file

@ -0,0 +1,27 @@
# Restart Policies
Restart policies control whether and how Docker attempts to restart a container.
| option | description |
| ------ | --- |
| no | does not restart automatically |
| on-failure[:max-retry] | restarts only when the container exits with a non-zero exit code, and when it has been restarted fewer than max-retry times. |
| always | always restarts the container if it stops. If it is manually stopped, it is restarted only when Docker daemon restarts or the container itself is manually restarted. |
| unless-stopped - always restarts the container unless it is manually stopped. Does not restart when the docker daemon is restarted. |
If no restart policy is provided, the default is no.
## Example
```yaml
version: '3.3'
services:
simple-torrent:
ports:
- '3000:3000'
volumes:
- '/path/to/my/downloads:/downloads'
- '/path/to/my/torrents:/torrents'
image: boypt/cloud-torrent
restart: unless-stopped
```