How to access ipv6 host from docker container? - docker

On my host machine the ipv6 is working:
bessarabov#5:~$ curl --silent --verbose ipv6.google.com 2>&1 | head
* Rebuilt URL to: ipv6.google.com/
* Trying 2a00:1450:4010:c04::71...
* Connected to ipv6.google.com (2a00:1450:4010:c04::71) port 80 (#0)
> GET / HTTP/1.1
> Host: ipv6.google.com
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Mon, 01 Feb 2016 08:44:04 GMT
But inside docker there is no ipv6:
$ docker run --rm -it ubuntu:14.04.3 bash
root#54c52afa87ee:/# ifconfig
eth0 Link encap:Ethernet HWaddr 02:42:ac:11:00:02
inet addr:172.17.0.2 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::42:acff:fe11:2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:648 (648.0 B) TX bytes:648 (648.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
root#54c52afa87ee:/# apt-get install -y curl
...
root#54c52afa87ee:/# curl --silent --verbose ipv6.google.com 2>&1 | head
* Rebuilt URL to: ipv6.google.com/
* Hostname was NOT found in DNS cache
* Trying 2a00:1450:4010:c04::71...
* Immediate connect fail for 2a00:1450:4010:c04::71: Network is unreachable
* Closing connection 0
root#54c52afa87ee:/#
What should I do to be able to access ipv6 host from docker container?
I'm using docker on my mac. I've installed it with docker-toolbox.
bessarabov#5:~$ docker version
Client:
Version: 1.9.1
API version: 1.21
Go version: go1.4.3
Git commit: a34a1d5
Built: Fri Nov 20 17:56:04 UTC 2015
OS/Arch: darwin/amd64
Server:
Version: 1.9.1
API version: 1.21
Go version: go1.4.3
Git commit: a34a1d5
Built: Fri Nov 20 17:56:04 UTC 2015
OS/Arch: linux/amd64
bessarabov#5:~$ docker-machine ls
NAME ACTIVE URL STATE URL SWARM DOCKER ERRORS
default * virtualbox Running tcp://192.168.99.100:2376 v1.9.1
bessarabov#5:~$

from the doc
https://docs.docker.com/engine/userguide/networking/default_network/ipv6/
I see
By default, the Docker server configures the container network for IPv4 only. You can enable IPv4/IPv6 dualstack support by running the Docker daemon with the --ipv6 flag.
Do you start the docker daemon with IPv6 ?

Related

freeipa-server container won't start in docker compose

Host OS is Ubuntu 19.10. I've been successful in starting the FreeIPA container using docker run, but I'd like to get it working in compose. When I run docker-compose up, freeipa crashes with the following error:
IPv6 stack is enabled in the kernel but there is no interface that has
::1 address assigned. Add ::1 address resolution to 'lo' interface.
You might need to enable IPv6 on the interface 'lo' in sysctl.conf.
My current config:
freeipa:
image: freeipa/freeipa-server
command:
[
"--realm=${ROOT_DOMAIN}",
"--ds-password=${LDAP_USER_PASSWORD}",
"--admin-password=${LDAP_ADMIN_PASSWORD}",
"-U",
]
hostname: ${FREEIPA_DOMAIN}
container_name: freeipa
restart: unless-stopped
labels:
- "traefik.enable=true"
- "traefik.http.routers.freeipa.rule=Host(`${FREEIPA_DOMAIN:?Domain for Freeipa must be set!}`)"
- "traefik.http.routers.freeipa.entrypoints=secure"
- "traefik.http.routers.freeipa.tls.certresolver=le"
networks:
- proxy
volumes:
- ${SERVICES_ROOT}/${FREEIPA_ROOT:-freeipa}/db:/data
- ${SERVICES_ROOT}/${FREEIPA_ROOT:-freeipa}/logs:/var/logs
- /sys/fs/cgroup:/sys/fs/cgroup:ro
tmpfs:
- /run
- /var/cache
- /tmp
Link to the full (very large) compose file here
I've enabled ipv6 in Docker and reloaded the daemon:
cat /etc/docker/daemon.json
{
"ipv6": true,
"fixed-cidr-v6": "2001:db8:1::/64"
}
Following this blog post, I checked the interface configuration within a container:
$: docker run -itd ajeetraina/ubuntu-iproute bash
f549ae3efe887fe45a1594c87516b948cebbbb6916a6550d738e3271200bd9b7
$: docker exec -it f549 ifconfig
eth0 Link encap:Ethernet HWaddr 02:42:ac:11:00:02
inet addr:172.17.0.2 Bcast:172.17.255.255 Mask:255.255.0.0
inet6 addr: fe80::42:acff:fe11:2/64 Scope:Link
inet6 addr: 2001:db8:1::242:ac11:2/64 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:21 errors:0 dropped:0 overruns:0 frame:0
TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3722 (3.7 KB) TX bytes:726 (726.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
It seems like there shouldn't be an issue with the loopback device from what I'm seeing here.
I have found the answer in an unrelated Github issue. Adding
sysctls:
- net.ipv6.conf.all.disable_ipv6=0
to the service definition fixes the problem. I hope this helps someone!

Way to assign Linux container to the same LAN as host? [duplicate]

This question already has an answer here:
DOCKER: Linux Container on Windows 10, how to use nmap to scan device's mac address
(1 answer)
Closed 2 years ago.
My goal is to make my Linux container live on the same lan as host and other devices.
Because I need to use nmap frequently to scan the devices mac address on the lan. Unfortunately, the nmap scanning is only working when these machines all live on the same subnet.
I've tried several ways to make it happen, but all failed.
Although there are lots of instructions about how to do this, seem like they are all for Docker for Linux.
For example, a very detailed instructions from stackoverflow:
Docker on CentOS with bridge to LAN network is also not working for me.
Things I've tried:
Macvlan:
it seems like Docker for Windows 10 doesn't support macvlan due to I have no way to make Windows network adapter as parent..
Pipework:
which is only working on Linux system but I am using Windows 10..
Modify bip from daemon.json:
I tried, which will set docker0 to static IP then container is still not able to ping devices on the LAN. I guess it's because the container is placed at NAT and change docker0 bridge ip won't be able to achieve my goal.
Run image with --net host:
which ifconfig shows:
docker0 Link encap:Ethernet HWaddr 02:42:2d:b8:0b:7c
inet addr:172.17.0.1 Bcast:172.17.255.255 Mask:255.255.0.0
inet6 addr: fe80::42:2dff:feb8:b7c/64 Scope:Link
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:540 (540.0 B)
eth0 Link encap:Ethernet HWaddr 02:50:00:00:00:01
inet addr:192.168.65.3 Bcast:192.168.65.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:111 errors:0 dropped:0 overruns:0 frame:0
TX packets:147 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:9701 (9.7 KB) TX bytes:10384 (10.3 KB)
hvint0 Link encap:Ethernet HWaddr 00:15:5d:0d:52:27
inet addr:10.0.75.2 Bcast:0.0.0.0 Mask:255.255.255.0
inet6 addr: fe80::215:5dff:fe0d:5227/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:359819 errors:0 dropped:1303 overruns:0 frame:0
TX packets:1157 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:54740692 (54.7 MB) TX bytes:103676 (103.6 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:57 errors:0 dropped:0 overruns:0 frame:0
TX packets:57 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:5732 (5.7 KB) TX bytes:5732 (5.7 KB)
It's able to ping everything on my subnet, but the IP is still not from my subnet but 192.168.65.3.
Then I was trying to change the eth0 ip to static IP by editing /etc/network/interface.d/eth0, after restart networking service, the eth0 ip is changed to static ip from my subnet, but the network is not working anymore.
PLEASE, if anyone here knows how to place Windows 10's Linux Container on the LAN as same as host's.
My Docker Version
Client:
Version: 18.03.1-ce
API version: 1.37
Go version: go1.9.5
Git commit: 9ee9f40
Built: Thu Apr 26 07:12:48 2018
OS/Arch: windows/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.03.1-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.9.5
Git commit: 9ee9f40
Built: Thu Apr 26 07:22:38 2018
OS/Arch: linux/amd64
Experimental: false
I'm still working on this, but your assertion that macvlan doesn't work on Windows 10 is incorrect. Using some of the instructions in the question you linked, I got a fairly functional macvlan network set up on Windows 10. I'm still wrestling with getting hosts on my network to be able to ping hosts on the macvlan network.
Here's what I did:
In an admin powershell window: Set-NetIPInterface -ifindex <interface_index> -Forwarding Enabled setting (use Get-NetAdapter to get list of network adapters and their ifindex numbers)
docker network create routed0 --subnet 192.168.2.0/24 replacing 192.168.2.0/24 with the correct network number and netmask bits for the network you want to assign to the routed0 network
For me, this yielded a docker network via which attached containers could successfully talk with internet hosts via the router for 192.168.1.0/24. However, I have yet to figure out how to configure the windows 10 box acting as the gateway for 192.168.2.0/24 to actually act as a gateway (and do things like route ICMP requests from hosts on 1.0/24 to the docker network 2.0/24 that it's hosting).
I had posted another question which is the same root cause of this question. Therefore, they could apply to the same solution.
The solution is post on
DOCKER: Linux Container on Windows 10, how to use nmap to scan device's mac address

Static IP on docker container not working

My ISP has given me a 10 IP addresses. x.x.x.91-95 and x.x.x.161-165
I want to use 9 of them for my containers.
I have the host eth0 on x.x.x.91
So I did:
docker network create --subnet x.x.x.0/24 --gateway x.x.x.254 mynet
and then
docker run -it --net mynet --ip x.x.x.165 ubuntu /bin/bash
But I can't connect out
PING 8.8.8.8 (8.8.8.8): 56 data bytes
3 packets transmitted, 0 packets received, 100% packet loss
# ifconfig
eth0 Link encap:Ethernet HWaddr 02:42:5b:cc:d2:a5
inet addr:x.x.x.165 Bcast:0.0.0.0 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:16 errors:0 dropped:0 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1296 (1.2 KB) TX bytes:504 (504.0 B)
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 x.x.x.254 0.0.0.0 UG 0 0 0 eth0
x.x.x.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
Any ideas?
Docker version 17.09.0-ce, build afdb6d4
I switched to the Macvlan driver (as suggested by Matt)
https://docs.docker.com/engine/userguide/networking/get-started-macvlan/

Containers on different hosts are not reachable

I have a stack with 2 servcies:
1. dockercloud/haproxy as load balancer
2. mycustom/nginx for ssl termination
I have 2 hosts and each service has 2 containers. One on every host.
Host 1:
* Haproxy-1 (IP: 10.7.0.9)
* Nginx-1 (IP: 10.7.0.7)
Host 2:
* Haproxy 2 (IP: 10.7.0.10)
* Nginx 2 (IP: 10.7.0.8)
The problem is that i can't connect from a container on host 1 to a container on host 2.
When connecting on host 1 and trying to traceroute Haproxy 2 (10.7.0.7) i get this:
traceroute to 10.7.0.7 (10.7.0.7), 30 hops max, 60 byte packets 1
10.7.255.254 (10.7.255.254) 2997.863 ms !H 2997.704 ms !H 2997.684 ms !H
Any suggestions how to fix this?
Edit
docker info
Containers: 12
Running: 11
Paused: 0
Stopped: 1
Images: 12
Server Version: 1.11.1-cs1
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 90
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: null host bridge weavemesh
Kernel Version: 3.16.0-4-amd64
Operating System: Debian GNU/Linux 8 (jessie)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 5.813 GiB
Name: Debian-85-jessie-64-minimal
ID: BV3I:KVWH:L45Q:CV2D:IOTX:BG7W:YAUV:S4QG:AJ44:BTVK:J3VJ:RWJA
Docker Root Dir: /var/lib/docker
Debug mode (client): false
Debug mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No memory limit support
WARNING: No swap limit support
WARNING: No kernel memory limit support
WARNING: No oom kill disable support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support
docker version
Client:
Version: 1.11.1-cs1
API version: 1.23
Go version: go1.5.4
Git commit: bfd1f99
Built: Wed Apr 27 22:35:34 2016
OS/Arch: linux/amd64
Server:
Version: 1.11.1-cs1
API version: 1.23
Go version: go1.5.4
Git commit: bfd1f99
Built: Wed Apr 27 22:35:34 2016
OS/Arch: linux/amd64
docker network ls
NETWORK ID NAME DRIVER
719bbcb667f2 bridge bridge
acb91ed95ada dockercloud weavemesh
c4be8b540ad6 host host
c57e28b9d274 none null
8d3859eb8bfd weave weavemesh
I used dockercloud to setup the services. So i didn't use any commands on my own.
EDIT 2
Here is ifconfig of nginx-1:
eth0 Link encap:Ethernet HWaddr 02:42:AC:11:00:07
inet addr:172.17.0.7 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::42:acff:fe11:7%32596/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:530 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:45267 (44.2 KiB) TX bytes:956 (956.0 B)
ethwe1 Link encap:Ethernet HWaddr DE:1C:3F:DF:E9:0C
inet addr:10.7.0.7 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::dc1c:3fff:fedf:e90c%32596/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1410 Metric:1
RX packets:62 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:5164 (5.0 KiB) TX bytes:648 (648.0 B)
Here is ifconfig of nginx-2:
eth0 Link encap:Ethernet HWaddr 02:42:AC:11:00:08
inet addr:172.17.0.8 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::42:acff:fe11:8%32566/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:174 errors:0 dropped:0 overruns:0 frame:0
TX packets:21 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:14399 (14.0 KiB) TX bytes:2076 (2.0 KiB)
ethwe1 Link encap:Ethernet HWaddr B2:A0:36:AF:0B:95
inet addr:10.7.0.8 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::b0a0:36ff:feaf:b95%32566/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1410 Metric:1
RX packets:643722 errors:0 dropped:0 overruns:0 frame:0
TX packets:369311 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:66498273 (63.4 MiB) TX
bytes:31055890 (29.6 MiB)

Connection Failing to Docker Container

Here is how I run my docker container -
docker run --name docker-test-server -p 5000:5000 -p 4444:4444
Container OS - Ubuntu 14.04 LTS
Now since I have mapped 4444 of container to that of machine, I try to connect -
root#localhost:/var/repo# nc -vz 127.0.0.1 4444
Connection to 127.0.0.1 4444 port [tcp/*] succeeded!
Now I enter the shell -
docker exec -it docker-test-server /bin/bash
Successfully entering, I try to get the IP address of the machine.
root#ec919687cda8:/# ifconfig
eth0 Link encap:Ethernet HWaddr 02:42:ac:11:00:09
inet addr:172.17.0.9 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::42:acff:fe11:9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2227 errors:0 dropped:0 overruns:0 frame:0
TX packets:2199 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:166686 (166.6 KB) TX bytes:121473 (121.4 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Now I come out of the container, and try to connect to the container from the machine where the container is running by providing the IP address of container found in ifconfig -
nc -vz 172.17.0.9 4444
nc: connect to 172.17.0.9 port 4444 (tcp) failed: Connection refused
Could someone, please explain me
why am I unable to connect to the machine?
What can I do to connect to the machine?
I am running a bare container that just installs ubuntu 14.04 and exposes 2 ports. Nothing fancy.
Thanks.
You need to either disable the firewall or add port to your ubuntu firewall by using sudo ufw disable or sudo ufw
I was also facing the same issue but instead of connection refused, I got timeout.

Resources