Skip to content

Enable IPv6 connectivity for the kamal network#1381

Closed
frenkel wants to merge 2 commits intobasecamp:mainfrom
frenkel:kamal-ipv6
Closed

Enable IPv6 connectivity for the kamal network#1381
frenkel wants to merge 2 commits intobasecamp:mainfrom
frenkel:kamal-ipv6

Conversation

@frenkel
Copy link
Copy Markdown

@frenkel frenkel commented Jan 27, 2025

Based on #1280 I've updated the tests as well.
This change is needed if you want to receive the client IPv6 address in your Rails app. Without it you'll only get the IPv4 address of the docker proxy (172.x.x.x).

@djmb
Copy link
Copy Markdown
Collaborator

djmb commented Jan 30, 2025

The integration tests are failing with "Error response from daemon: could not find an available, non-overlapping IPv6 address pool among the defaults to assign to the network".

This might just be from running docker inside docker, but it highlights that maybe this isn't a safe change in all contexts.

From the latest changes in main, the pre-deploy hook will always run before attempting to create the network, so the best solution here might be to use that to create a kamal network with whatever options you want.

@frenkel
Copy link
Copy Markdown
Author

frenkel commented Jan 30, 2025

Indeed, you would need some options in your docker file (or pass them as arguments). Hadn't thought about that and locally I did have those probably.

pre-deploy seems like a better solution, thanks for the hint! You might want to close #1280 then as well.

@disbelief
Copy link
Copy Markdown

So neither of the PRs addressing this appear to have been merged, or have I missed something?

@acidtib
Copy link
Copy Markdown
Contributor

acidtib commented Apr 10, 2025

@disbelief did you read the comments in the closed PR?

@disbelief
Copy link
Copy Markdown

@acidtib I don't see any comments. What am I missing?

#1280

@frenkel
Copy link
Copy Markdown
Author

frenkel commented Apr 11, 2025

Just create the kamal network yourself with the ipv6 option before deploying anything and you're good to go. You might need to enable some options in daemon.json, like this:

{
	"userland-proxy": false,
	"ipv6": true,
	"ip6tables": true,
	"fixed-cidr-v6": "2001:db8::/32",
	"experimental": true,
	"default-address-pools": [
		{ "base": "172.17.0.0/16", "size": 16 },
		{ "base": "172.18.0.0/16", "size": 16 },
		{ "base": "172.19.0.0/16", "size": 16 },
		{ "base": "172.20.0.0/14", "size": 16 },
		{ "base": "172.24.0.0/14", "size": 16 },
		{ "base": "172.28.0.0/14", "size": 16 },
		{ "base": "192.168.0.0/16", "size": 20 },
		{ "base": "2001:db8::/104", "size": 112 }
	]
}

@unasuke
Copy link
Copy Markdown

unasuke commented Mar 19, 2026

The CI failure that led to closing this PR no longer reproduces. It was caused by Docker < 27.0 lacking automatic IPv6 address pool allocation. Docker 27.0 (released June 2024) introduced automatic ULA allocation, so docker network create --ipv6 now works without explicit --subnet or default-address-pools configuration. (investigated by claude, but I've confirmed too)

I've verified this on a fork — all CI jobs pass

The suggested workaround (pre-creating the network via a hook) has a discoverability problem: https://kamal-deploy.org/docs/ does not mention that Kamal creates a kamal Docker network, nor how to customize it. Users on IPv6-only hosts (it's my own use-case!) have no way to discover this workaround without reading the source code.

The --ipv6 flag is safe on dual-stack hosts and essential on IPv6-only hosts. Would you be open to reconsidering this change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants