Tangled is a git platform built on the AT Protocol, with "knot servers" serving as repositories rather than the user PDS. This Dockerized version of the official knot server is unaffiliated with the developers of Tangled or the AT Protocol.
-
Docker: Ensure Docker is installed on your system. You can download and install Docker from here. For a comprehensive introduction to Docker, consider watching the following tutorial:
-
Docker Compose: Verify that Docker Compose is installed. Docker Compose is included with Docker Desktop, or you can install it separately by following the instructions here.
-
Cloudflare Tunnel: If you plan to route your server through a Cloudflare Tunnel, install and configure
cloudflaredon your Ubuntu server.
-
Install
cloudflaredcurl -fsSL https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o cloudflared chmod +x cloudflared sudo mv cloudflared /usr/local/bin/
-
Authenticate Cloudflare Tunnel
cloudflared tunnel login
This will open a browser where you must log into your Cloudflare account and authorize
cloudflared. -
Create a new Cloudflare Tunnel
cloudflared tunnel create my-tunnel
Replace
my-tunnelwith a name of your choice. -
Configure the Tunnel
sudo mkdir -p /etc/cloudflared sudo nano /etc/cloudflared/config.yml
Add the following:
tunnel: my-tunnel credentials-file: /root/.cloudflared/my-tunnel.json ingress: - hostname: yourdomain.com service: http://localhost:5555 - service: http_status:404
Replace
yourdomain.comwith your actual domain. -
Run the Tunnel
cloudflared tunnel run my-tunnel
To run it as a service:
sudo cloudflared service install sudo systemctl start cloudflared sudo systemctl enable cloudflared
-
Clone the repository:
git clone https://github.com/ewanc26/knotted-docker.git cd knotted-docker -
Edit
.local.envto specify your local server's hostname and update the secret:KNOT_SERVER_HOSTNAME=your.local.server KNOT_SERVER_SECRET=your_secret
Security Note: Do not hardcode sensitive information in
.local.envif you plan to share your repository. Consider adding.local.envto.gitignoreto prevent accidental exposure. -
Build and run the Docker containers in the background using
docker compose:docker compose up --build -d
-
Access the server on the ports defined in the
docker-compose.ymlfile:- Knot Server:
http://your.local.server:5555 - Internal Listen Address:
127.0.0.1:5444
- Knot Server:
- Ensure your Cloudflare Tunnel routes traffic to
http://your.local.server:5555. - Access your server via the Cloudflare Tunnel URL you have set up.
-
Set up SSH for Git to work through your Cloudflare Tunnel:
- Configure your Cloudflare Tunnel to route traffic to your SSH server (typically running on port 22).
- Add a new service in your Cloudflare Tunnel configuration for SSH. For example, if your SSH server runs on
localhost:22, you can add a service like this:
cloudflared tunnel route dns <tunnel-name> git.yourdomain.com
- Update your SSH configuration by editing your
~/.ssh/configfile to include:
Host git.yourdomain.com HostName git.yourdomain.com User git Port 22 ProxyCommand cloudflared access ssh --hostname %h- Replace
git.yourdomain.comwith the hostname configured in your Cloudflare Tunnel.
-
Update your Git remote URL to use the configured Cloudflare Tunnel:
git remote set-url origin ssh://git@git.yourdomain.com:22/your/repo.git
- Replace
git.yourdomain.comwith your configured hostname andyour/repo.gitwith your repository path.
- Replace
-
Clone your Git repository via SSH using the Cloudflare Tunnel:
git clone ssh://git@git.yourdomain.com:22/your/repo.git
If you found this useful, consider buying me a ko-fi!
-
List running Docker containers:
docker ps
-
Check the contents of the
/knotdirectory inside the running container:docker exec -it <container_id> ls -l /knot
-
Stop and remove the container:
docker stop <container_id> docker rm <container_id>
-
Remove the Docker volume to clear persistent data:
docker volume rm knotted-docker_knot_data
-
Rebuild and restart the Docker containers:
docker compose up --build -d
Following these steps should resolve the Already registered error and allow you to restart the Knot server successfully.