This is a text-only version of the following page on https://raymii.org: --- Title : IPv6 in a Docker container on a non-ipv6 network Author : Remy van Elst Date : 12-04-2016 URL : https://raymii.org/s/articles/IPv6_in_a_Docker_container_on_a_non-ipv6_network.html Format : Markdown/HTML --- At work and at home my ISP's have native IPv6. I recently was at a clients location where they had no IPv6 at all and had to set up and demonstrate an application in a Docker container with IPv6 functionality. They said the had IPv6 but on location it appeared that IPv6 wasn't working. Since IPv6 was required for the demo the container needed a workaround. This article describes the workaround I used to add IPv6 to a Docker container on a non IPv6 network. It was tested on an `Ubuntu 14.04` container, but should work for other Linux distro's as well.
The workaround involes installing `miredo` in the container to get a tunnel and an IPv6 connection that way. Extremely simple, but it required some extra parameters in the Docker workflow. [Miredo][2] is a client for the `teredo` protocol. On Ubuntu it is an easy way to add IPv6 to an IPv4 only system. Installing `miredo` and starting the service is enough. First I started the docker container with `docker run`, and added an extra parameter, the `--privileged` one, like so: docker run --privileged --name "$APPNAME" "$IMAGENAME" This gives the container the ability to create a `/dev/net/tun` device required for miredo. Otherwise you will get an error like below when starting `miredo`: /dev/net/tun does not exist. A Docker container is (to be) used for a single process (as opposed to for example an LXD or OpenVZ container, which are more suited for VPS-like operation) and therefore there is no SSH access or a service manager like `systemd` or `init`. Installing software should be done via the Dockerfile in a new container. I needed a way to install and start the `miredo` service outside of the Dockerfile for this one instance. Since this container was to be used only that occasion I used a rather dirty hack to get a shell in the container, install and start the service. It works, but it's not the best way (that would involve setting IPv6 up on the host and configuring the Docker network to also use that in the bridge). Get the container ID with `docker ps`: docker ps Output: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 7522a5aedc8b 7.0-apache-openssl-1.1.0 "apache2-foreground" About an hour ago Up About an hour 80/tcp testapp Open a shell inside of the container, replacing the ID with your container ID: docker exec -i -t 7522a5aedc8b bash This gives you a `bash` prompt in the container. Install the `miredo` package: apt-get update && apt-get install miredo Start the service: service miredo start Check if the new interface (`miredo`) exists and is up: 2: teredo: