Add 'docker/' from commit '40df5c877e3894e7c62fe21ddba6ddfe50cc96a0'

git-subtree-dir: docker
git-subtree-mainline: 83c64454b7
git-subtree-split: 40df5c877e
main
mat ess 2022-10-19 01:18:41 -04:00
commit ddd291cc57
7 changed files with 144 additions and 0 deletions

14
docker/Dockerfile Normal file
View File

@ -0,0 +1,14 @@
FROM docker:dind
RUN apk add bash ip6tables pigz sysstat procps lsof gcompat
COPY etc/docker/daemon.json /etc/docker/daemon.json
COPY ./entrypoint ./entrypoint
COPY ./docker-entrypoint.d/* ./docker-entrypoint.d/
ENV DOCKER_TMPDIR=/data/docker/tmp
ENTRYPOINT ["./entrypoint"]
CMD ["dockerd", "-p", "/var/run/docker.pid"]

26
docker/README.md Normal file
View File

@ -0,0 +1,26 @@
# Fly Docker Daemon
This is a Docker Daemon that runs on Fly.io and can be used to offload builds and other tasks to a Fly app running in a city near you.
## Installation
1. Clone this repository
1. `fly launch`, follow the prompts
1. Select `n` when it asks if you want to deploy
1. Create a volume in a region of your choice: `fly volumes create data --size 50 --region ord`
1. Deploy
## Get Connected
1. Create a WireGuard peer with `fly wireguard create`
1. Setup WireGuard with generated config
1. `fly ips private` to get the IP of your Daemon
1. Set the `DOCKER_HOST` env variable using that IP:
```
export DOCKER_HOST=tcp://[fdaa:0:5d2:a7b:81:0:26d4:2]:2375
```
# Final Step
1. Delete the Docker Engine from your local system.
1. You probably want to scale your remote Daemon: `fly scale vm dedicated-cpu-2x`

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -e
echo "Setting up Docker data directory"
mkdir -p /data/docker
echo "Configuring ipv6 for docker"
ip6tables -t nat -A POSTROUTING -s 2001:db8:1::/64 ! -o docker0 -j MASQUERADE
echo "Done setting up docker!"

View File

@ -0,0 +1,46 @@
#!/bin/bash
set -e
echo "Allowing ipv6 forwarding via sysctl"
sysctl net.ipv6.conf.default.forwarding=1
sysctl net.ipv6.conf.all.forwarding=1
echo "General sysctl tweaks"
sysctl vm.swappiness=0
sysctl vm.dirty_ratio=6
sysctl vm.dirty_background_ratio=3
# Default Socket Receive Buffer
sysctl net.core.rmem_default=31457280
# Maximum Socket Receive Buffer
sysctl net.core.rmem_max=33554432
# Default Socket Send Buffer
sysctl net.core.wmem_default=31457280
# Maximum Socket Send Buffer
sysctl net.core.wmem_max=33554432
# Increase number of incoming connections
sysctl net.core.somaxconn=65535
# Increase number of incoming connections backlog
sysctl net.core.netdev_max_backlog=65536
# Increase the maximum amount of option memory buffers
sysctl net.core.optmem_max=25165824
# Increase the maximum total buffer-space allocatable
# This is measured in units of pages (4096 bytes)
sysctl "net.ipv4.tcp_mem=786432 1048576 26777216"
sysctl "net.ipv4.udp_mem=65536 131072 262144"
# Increase the read-buffer space allocatable
sysctl "net.ipv4.tcp_rmem=8192 87380 33554432"
sysctl net.ipv4.udp_rmem_min=16384
# Increase the write-buffer-space allocatable
sysctl "net.ipv4.tcp_wmem=8192 65536 33554432"
sysctl net.ipv4.udp_wmem_min=16384

13
docker/entrypoint Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
set -e
if [[ -d "docker-entrypoint.d" ]]
then
echo "Running docker-entrypoint.d files"
/bin/run-parts docker-entrypoint.d
fi
echo "Running $@"
exec "$@"

View File

@ -0,0 +1,27 @@
{
"data-root": "/data/docker",
"experimental": true,
"ipv6": true,
"ip6tables": true,
"fixed-cidr-v6": "2001:db8:1::/64",
"default-address-pools": [
{
"base": "10.100.0.1/16",
"size": 24
}
],
"debug": true,
"log-level": "debug",
"features": {
"buildkit": false
},
"hosts": [
"unix:///var/run/docker.sock",
"tcp://[::]:2375"
],
"mtu": 1400,
"max-concurrent-downloads": 10,
"max-concurrent-uploads": 5,
"metrics-addr": "0.0.0.0:9323",
"tls": false
}

7
docker/fly.toml Normal file
View File

@ -0,0 +1,7 @@
app = "rem"
kill_signal = "SIGINT"
kill_timeout = 5
[[mounts]]
destination = "/data"
source = "data"