Score:0

Docker wagtail ERR_ADDRESS_UNREACHABLE

ru flag

Just created the mysite example from https://github.com/wagtail/wagtail.

Running fine with python manage.py runserver

Instead if I build and run from docker I get:

ERR_ADDRESS_UNREACHABLE

docker build .

docker run name

+ gunicorn mysite.wsgi:application
[2023-07-17 09:08:44 +0000] [9] [INFO] Starting gunicorn 20.0.4
[2023-07-17 09:08:44 +0000] [9] [INFO] Listening at: http://0.0.0.0:8000 (9)
[2023-07-17 09:08:44 +0000] [9] [INFO] Using worker: sync
[2023-07-17 09:08:44 +0000] [11] [INFO] Booting worker with pid: 11

docker inspect:

        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "6ae09fa43e67fd3a12a82d1f52df5969233779629d3ea36c760e2485b68fdcfc",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "8000/tcp": null
            },
            "SandboxKey": "/run/user/1000/docker/netns/6ae09fa43e67",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "df243e870b2f1006b12e54d3430481b3ce139e2ee1533ef7c05ff8543d7f49cb",
            "Gateway": "172.17.0.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.0.2",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "02:42:ac:11:00:02",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "90bd3af32cbd57398805e41e4effd604584248c1fddcb0e76048714f92aab7d8",
                    "EndpointID": "df243e870b2f1006b12e54d3430481b3ce139e2ee1533ef7c05ff8543d7f49cb",
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:02",
                    "DriverOpts": null
                }
            }
        }
    }
]

It seems that docker interfaces are DOWN:

systemctl status docker


● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; preset: enabled)
     Active: active (running) since Mon 2023-07-17 11:51:31 CEST; 17min ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 2065 (dockerd)
      Tasks: 14
     Memory: 139.6M
        CPU: 960ms
     CGroup: /system.slice/docker.service
             └─2065 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock


lug 17 11:51:31 tec1-20en0000pc dockerd[2065]: time="2023-07-17T11:51:31.072075899+02:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address"

ip a

4: br-89b723d5bb07: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:55:8f:fd:a5 brd ff:ff:ff:ff:ff:ff
    inet 172.22.0.1/16 brd 172.22.255.255 scope global br-89b723d5bb07
       valid_lft forever preferred_lft forever
5: br-9c6e73ff1b4d: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:36:5e:4c:5a brd ff:ff:ff:ff:ff:ff
    inet 172.18.0.1/16 brd 172.18.255.255 scope global br-9c6e73ff1b4d
       valid_lft forever preferred_lft forever
6: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:5d:d4:50:e3 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
7: br-e461558f2119: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:f4:87:f4:51 brd ff:ff:ff:ff:ff:ff
    inet 172.19.0.1/16 brd 172.19.255.255 scope global br-e461558f2119
       valid_lft forever preferred_lft forever

docker version:

Client: Docker Engine - Community
 Version:           24.0.4
 API version:       1.43
 Go version:        go1.20.5
 Git commit:        3713ee1
 Built:             Fri Jul  7 14:51:04 2023
 OS/Arch:           linux/amd64
 Context:           rootless

Server: Docker Engine - Community
 Engine:
  Version:          24.0.4
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.5
  Git commit:       4ffc614
  Built:            Fri Jul  7 14:51:04 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.21
  GitCommit:        3dce8eb055cbb6872793272b4f20ed16117344f8
 runc:
  Version:          1.1.7
  GitCommit:        v1.1.7-0-g860f061
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
 rootlesskit:
  Version:          1.1.1
  ApiVersion:       1.1.1
  NetworkDriver:    slirp4netns
  PortDriver:       builtin
  StateDir:         /tmp/rootlesskit4197084671
 slirp4netns:
  Version:          1.2.0
  GitCommit:        656041d45cfca7a4176f6b7eed9e4fe6c11e8383
jp flag
You don't have any port mapping defined in `docker run` command.
user340971 avatar
ru flag
Thanks! I was thinking that by default the 172.17.0.2 was reachable. Added the ports and works fine.
Score:0
jp flag

To reach the container over a network you need to have port mapping defined in docker run command.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.