Checking IPv6 in your container
To check if IPv6 is enabled in your container, run a terminal in your container and run the following commands:
Adapt this to the appropriate package manager for the base distro of your container, e.g. apk add
for alpine
Configuring IPv6
Using an IPv6 host
If you are defining the host of your server directly, e.g. with a host oflocalhost
, replace it with the IPv6
equivalent ::
Equivalently replace a host of 0.0.0.0
with the IPv6 equivalent*
.
Uvicorn
uvicorn main:app --host '::' --port 1234
Gunicorn
gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app --bind '[::]:1234'
Node.js
Express.js
Fastify
IPv6 with socat in custom containers
If you have direct access to the dockerfile used to create your image, you can modify it to install and startsocat
which will forward IPv6 to IPv4. For the example below, you would enter port 8888 for SaladCloud, which would then be
routed to IPv4 port 8080. Adapt as needed for your setup. Alternatively, the socat
command can be included in an
entryfile or setup script. Once you’ve rebuilt the image, check with netstat
as above to verify it has worked.

IPv6 with cog through socat
If you are using cog to create your container, a few small changes can enablesocat
to route IPv6 to IPV4 within the container.
-
Add socat to the
system_packages
section ofcog.yaml
. For example, -
In predict.py (or other file included in the
predict
section ofcog.yaml
) addimport os
, and addos.system("socat TCP6-LISTEN:8888,fork TCP4:127.0.0.1:5000 &")
tosetup
. Update5000
to the port your container is expecting. The other port, here, 8888 is what would be used when setting up the container group deployment.
