├── Dockerfile ├── README.md ├── docker-entrypoint.d ├── docker └── sysctl ├── entrypoint ├── etc └── docker │ └── daemon.json └── fly.toml /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM docker/buildx-bin:v0.12 as buildx 2 | 3 | FROM docker:24-dind 4 | 5 | RUN apk add bash pigz sysstat procps lsof 6 | 7 | COPY etc/docker/daemon.json /etc/docker/daemon.json 8 | 9 | COPY --from=buildx /buildx /root/.docker/cli-plugins/docker-buildx 10 | 11 | COPY ./entrypoint ./entrypoint 12 | COPY ./docker-entrypoint.d/* ./docker-entrypoint.d/ 13 | 14 | ENV DOCKER_TMPDIR=/data/docker/tmp 15 | 16 | ENTRYPOINT ["./entrypoint"] 17 | 18 | CMD ["dockerd", "-p", "/var/run/docker.pid"] 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Fly Docker Daemon 2 | 3 | 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. 4 | 5 | ## Installation 6 | 7 | 1. Clone this repository 8 | 1. `fly launch`, follow the prompts 9 | 1. Select `n` when it asks if you want to deploy 10 | 1. Create a volume in a region of your choice: `fly volumes create data --size 50 --region ord` 11 | 1. Deploy 12 | 13 | ## Get Connected 14 | 15 | 1. Create a WireGuard peer with `fly wireguard create` 16 | 1. Setup WireGuard with generated config 17 | 1. `fly ips private` to get the IP of your Daemon 18 | 1. Set the `DOCKER_HOST` env variable using that IP: 19 | ``` 20 | export DOCKER_HOST=tcp://[fdaa:0:5d2:a7b:81:0:26d4:2]:2375 21 | ``` 22 | 23 | # Final Step 24 | 25 | 1. Delete the Docker Engine from your local system. 26 | 1. You probably want to scale your remote Daemon: `fly scale vm dedicated-cpu-2x` -------------------------------------------------------------------------------- /docker-entrypoint.d/docker: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | echo "Setting up Docker data directory" 6 | mkdir -p /data/docker 7 | 8 | echo "Configuring ipv6 for docker" 9 | ip6tables-legacy -t nat -A POSTROUTING -s 2001:db8:1::/64 ! -o docker0 -j MASQUERADE 10 | 11 | echo "Done setting up docker!" 12 | -------------------------------------------------------------------------------- /docker-entrypoint.d/sysctl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | echo "Allowing ipv6 forwarding via sysctl" 6 | sysctl net.ipv6.conf.default.forwarding=1 7 | sysctl net.ipv6.conf.all.forwarding=1 8 | 9 | echo "General sysctl tweaks" 10 | sysctl vm.swappiness=0 11 | sysctl vm.dirty_ratio=6 12 | sysctl vm.dirty_background_ratio=3 13 | 14 | # Default Socket Receive Buffer 15 | sysctl net.core.rmem_default=31457280 16 | 17 | # Maximum Socket Receive Buffer 18 | sysctl net.core.rmem_max=33554432 19 | 20 | # Default Socket Send Buffer 21 | sysctl net.core.wmem_default=31457280 22 | 23 | # Maximum Socket Send Buffer 24 | sysctl net.core.wmem_max=33554432 25 | 26 | # Increase number of incoming connections 27 | sysctl net.core.somaxconn=65535 28 | 29 | # Increase number of incoming connections backlog 30 | sysctl net.core.netdev_max_backlog=65536 31 | 32 | # Increase the maximum amount of option memory buffers 33 | sysctl net.core.optmem_max=25165824 34 | 35 | # Increase the maximum total buffer-space allocatable 36 | # This is measured in units of pages (4096 bytes) 37 | sysctl "net.ipv4.tcp_mem=786432 1048576 26777216" 38 | sysctl "net.ipv4.udp_mem=65536 131072 262144" 39 | 40 | # Increase the read-buffer space allocatable 41 | sysctl "net.ipv4.tcp_rmem=8192 87380 33554432" 42 | sysctl net.ipv4.udp_rmem_min=16384 43 | 44 | # Increase the write-buffer-space allocatable 45 | sysctl "net.ipv4.tcp_wmem=8192 65536 33554432" 46 | sysctl net.ipv4.udp_wmem_min=16384 -------------------------------------------------------------------------------- /entrypoint: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | if [[ -d "docker-entrypoint.d" ]] 6 | then 7 | echo "Running docker-entrypoint.d files" 8 | /bin/run-parts docker-entrypoint.d 9 | fi 10 | 11 | echo "Running $@" 12 | 13 | exec "$@" -------------------------------------------------------------------------------- /etc/docker/daemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "data-root": "/data/docker", 3 | "experimental": true, 4 | "ipv6": true, 5 | "ip6tables": true, 6 | "fixed-cidr-v6": "2001:db8:1::/64", 7 | "default-address-pools": [ 8 | { 9 | "base": "10.100.0.1/16", 10 | "size": 24 11 | } 12 | ], 13 | "debug": true, 14 | "log-level": "debug", 15 | "features": { 16 | "buildkit": true 17 | }, 18 | "hosts": [ 19 | "unix:///var/run/docker.sock", 20 | "tcp://[::]:2375" 21 | ], 22 | "mtu": 1400, 23 | "max-concurrent-downloads": 10, 24 | "max-concurrent-uploads": 5, 25 | "metrics-addr": "0.0.0.0:9323", 26 | "tls": false 27 | } -------------------------------------------------------------------------------- /fly.toml: -------------------------------------------------------------------------------- 1 | # fly.toml file generated for docker-for-kurt on 2021-06-23T18:04:47-05:00 2 | 3 | app = "docker-for-kurt" 4 | 5 | kill_signal = "SIGINT" 6 | kill_timeout = 5 7 | 8 | [[mounts]] 9 | destination = "/data" 10 | source = "data" 11 | --------------------------------------------------------------------------------