docker daemon + setup
commit
33a6c04d19
|
@ -0,0 +1,24 @@
|
||||||
|
FROM alpine as buildx
|
||||||
|
|
||||||
|
RUN apk add curl jq
|
||||||
|
|
||||||
|
RUN mkdir -p /root/.docker/cli-plugins
|
||||||
|
RUN curl -L https://github.com/docker/buildx/releases/download/v0.5.1/buildx-v0.5.1.linux-amd64 > /root/.docker/cli-plugins/docker-buildx
|
||||||
|
RUN chmod a+x /root/.docker/cli-plugins/docker-buildx
|
||||||
|
|
||||||
|
FROM docker:20
|
||||||
|
|
||||||
|
RUN apk add bash ip6tables pigz sysstat procps lsof
|
||||||
|
|
||||||
|
COPY etc/docker/daemon.json /etc/docker/daemon.json
|
||||||
|
|
||||||
|
COPY --from=buildx /root/.docker /root/.docker
|
||||||
|
|
||||||
|
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", "--tls=false"]
|
|
@ -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`
|
|
@ -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!"
|
|
@ -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
|
|
@ -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 "$@"
|
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
"data-root": "/data/docker",
|
||||||
|
"ipv6": 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"
|
||||||
|
}
|
Loading…
Reference in New Issue