mdouchement / captive

Basic webserver used to fake Network Health Check (captive.apple.com - detectportal.firefox.com - etc.)
MIT License
1 stars 0 forks source link

Yaml file config - how to? #3

Open churchofnoise opened 2 years ago

churchofnoise commented 2 years ago

Hi,

Very happy to have found your excellent initiative here!

Just tried to run it using a basic yaml file but it seems not to work (I'm adding it to a file that already exists to create Pi-Hole and Unbound containers) When I look at running containers, this one is not up, but gives a time since restarting...

Is there anything I'm missing:

version: "3"

services:
  pihole:
    hostname: firewalla
    container_name: pihole
    image: pihole/pihole:nightly
    networks:
      default:
        ipv4_address: 172.16.0.2
    environment:
      TZ: [EDITED OUT]
      DNS1: '172.16.0.4'
      DNS2: '172.16.0.4'
      WEBPASSWORD: [EDITED OUT]
    volumes:
      - '/data/pi-hole/etc-pihole:/etc/pihole'
      - './etc-dnsmasq:/etc/dnsmasq.d'
      - '/etc/localtime:/etc/localtime:ro'
    restart: unless-stopped
    links:
      - unbound

  unbound:
    image: klutchell/unbound:main
    networks:
      default:
        ipv4_address: 172.16.0.4
    ports:
      - 5335:5335/tcp
      - 5335:5335/udp
    restart: unless-stopped
    volumes:
      - './unbound-conf:/etc/unbound/custom.conf.d'

  captive:
    image: mdouchement/captive:latest
    networks:
      default:
        ipv4_address: 172.16.0.5
    restart: unless-stopped

networks:
  default:
    driver: bridge
    ipam:
      config:
      - subnet: 172.16.0.0/24

Thanks in advance for the help!

mdouchement commented 2 years ago

Hello, there is no special configuration for this project. Did you try docker-compose logs captive or a docker inspect to see what's going on? 172.16.0.5 may be already used too.

churchofnoise commented 2 years ago

Thanks for your response!

Result of docker-compose logs captive:

Attaching to pi-hole_captive_1
captive_1  | standard_init_linux.go:228: exec user process caused: exec format error
captive_1  | standard_init_linux.go:228: exec user process caused: exec format error
captive_1  | standard_init_linux.go:228: exec user process caused: exec format error
captive_1  | standard_init_linux.go:228: exec user process caused: exec format error
captive_1  | standard_init_linux.go:228: exec user process caused: exec format error
captive_1  | standard_init_linux.go:228: exec user process caused: exec format error
captive_1  | standard_init_linux.go:228: exec user process caused: exec format error
captive_1  | standard_init_linux.go:228: exec user process caused: exec format error
captive_1  | standard_init_linux.go:228: exec user process caused: exec format error
captive_1  | standard_init_linux.go:228: exec user process caused: exec format error

And this is what docker inspect delivered:

[
    {
        "Id": "0a020bc5930df8de31fdaf514ddb6971899ddc513d8ccae72e95eb7c4e8d93b1",
        "Created": "2022-07-06T14:09:03.039772685Z",
        "Path": "captive",
        "Args": [],
        "State": {
            "Status": "restarting",
            "Running": true,
            "Paused": false,
            "Restarting": true,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 0,
            "ExitCode": 1,
            "Error": "",
            "StartedAt": "2022-07-06T14:12:19.063964878Z",
            "FinishedAt": "2022-07-06T14:12:19.096485365Z"
        },
        "Image": "sha256:a3d9fa3fc7097f830c6bff1399cfae81ae8dc91fb3daabda6e038409bc95c499",
        "ResolvConfPath": "/var/lib/docker/containers/0a020bc5930df8de31fdaf514ddb6971899ddc513d8ccae72e95eb7c4e8d93b1/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/0a020bc5930df8de31fdaf514ddb6971899ddc513d8ccae72e95eb7c4e8d93b1/hostname",
        "HostsPath": "/var/lib/docker/containers/0a020bc5930df8de31fdaf514ddb6971899ddc513d8ccae72e95eb7c4e8d93b1/hosts",
        "LogPath": "/var/lib/docker/containers/0a020bc5930df8de31fdaf514ddb6971899ddc513d8ccae72e95eb7c4e8d93b1/0a020bc5930df8de31fdaf514ddb6971899ddc513d8ccae72e95eb7c4e8d93b1-json.log",
        "Name": "/pi-hole_captive_1",
        "RestartCount": 12,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "docker-default",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "pi-hole_default",
            "PortBindings": {},
            "RestartPolicy": {
                "Name": "unless-stopped",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": [],
            "CapAdd": null,
            "CapDrop": null,
            "CgroupnsMode": "host",
            "Dns": null,
            "DnsOptions": null,
            "DnsSearch": null,
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "shareable",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": null,
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "KernelMemory": 0,
            "KernelMemoryTCP": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": null,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/c33088430dac12adc6aa9194bc39fe7f2c22652825bb2cd95ac0ad034cc32602-init/diff:/var/lib/docker/overlay2/769a05f37b99de7aaac7b58e451065434fbc6deb82ab5227ee340c1239c36e1d/diff",
                "MergedDir": "/var/lib/docker/overlay2/c33088430dac12adc6aa9194bc39fe7f2c22652825bb2cd95ac0ad034cc32602/merged",
                "UpperDir": "/var/lib/docker/overlay2/c33088430dac12adc6aa9194bc39fe7f2c22652825bb2cd95ac0ad034cc32602/diff",
                "WorkDir": "/var/lib/docker/overlay2/c33088430dac12adc6aa9194bc39fe7f2c22652825bb2cd95ac0ad034cc32602/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [],
        "Config": {
            "Hostname": "0a020bc5930d",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "8080/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "captive"
            ],
            "Image": "mdouchement/captive:latest",
            "Volumes": null,
            "WorkingDir": "/",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "com.docker.compose.config-hash": "80fcc159c40a6743f08a9911b302c1ea67ce766f14f0ee051b4f3520950f777c",
                "com.docker.compose.container-number": "1",
                "com.docker.compose.oneoff": "False",
                "com.docker.compose.project": "pi-hole",
                "com.docker.compose.project.config_files": "docker-compose.yaml",
                "com.docker.compose.project.working_dir": "/home/pi/.firewalla/run/docker/pi-hole",
                "com.docker.compose.service": "captive",
                "com.docker.compose.version": "1.25.0"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "10bef464e864931183881aecb60a144b5c866aad119dd61aec551390f0caeca3",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {},
            "SandboxKey": "/var/run/docker/netns/10bef464e864",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "pi-hole_default": {
                    "IPAMConfig": {
                        "IPv4Address": "172.16.0.5"
                    },
                    "Links": null,
                    "Aliases": [
                        "captive",
                        "0a020bc5930d"
                    ],
                    "NetworkID": "d277e9256dcac3fb1924e824d14c188f7c495e0b8be2c3b00558a2d0f36d0062",
                    "EndpointID": "",
                    "Gateway": "",
                    "IPAddress": "",
                    "IPPrefixLen": 0,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "",
                    "DriverOpts": null
                }
            }
        }
    }
]

The IP address is in a range created by the Docker yaml file, and only .2 and .4 are taken. Tried pinging .5 to be sure and no response, also not when the captive part is added.

Could this be architecture related? (see e.g. here

mdouchement commented 2 years ago

Yes it could, the image is built for linux amd64 by https://github.com/mdouchement/captive/blob/master/.github/workflows/docker.yml If that the case, GH action supports the build for several plateforms (even though I never tried): https://github.com/docker/build-push-action/blob/master/docs/advanced/multi-platform.md

You can try local build with docker build -t mdouchement/captive . from your Docker host.