Fabio: Q: Can't Load Docker Container

Created on 29 Jan 2017  路  15Comments  路  Source: fabiolb/fabio

On Centos7, I can't get the fabio Docker container working

Consul& Registrator

docker run -d --name consul -p 8500:8500 -p 172.17.0.1:53:8600/udp -p 8400:8400 gliderlabs/consul-server -node myconsul -bootstrap
docker run -d --name registrator -v /var/run/docker.sock:/tmp/docker.sock --net=host gliderlabs/registrator -internal consul://localhost:8500

both work fine, on default setups/ports

Bin
/usr/local/bin/fabio binary works fine

Trying Fabio Container

docker run -d -p 9999:9999 -p 9998:9998 -v content/config$PWD/fabio/fabio.properties:/etc/fabio/fabio.properties magiconair/fabio

This creates the container but exits it immediately, and won't start thereafter. Tried running /usr/local/bin/fabio concurrently, but no joy

Any ideas?
Regards

question

Most helpful comment

I'm no docker expert but this sequence of commands starts up fabio with consul in a Docker container. Maybe someone with more experience can comment on this:

docker pull consul
docker pull magiconair/fabio
docker run -d --name=consul -e 'CONSUL_BIND_INTERFACE=eth0' consul
docker logs consul # to get the ip address, in my case 172.17.0.2
docker run -d --name=fabio --link consul -e 'registry_consul_addr=172.17.0.2:8500' magiconair/fabio

I think the default bridge networking bridges the two eth0 interfaces between the containers but that doesn't (shouldn't) work for the lo0 interface. So the way I understand this is that 127.0.0.1 in the consul container is different from 127.0.0.1 in the fabio container since these two interfaces aren't bridged. But again, take all this with a huge grain of salt since I've just skimmed over the Docker networking documentation and augmented this with some assumptions on how networks can/should work.

All 15 comments

Don't you have to map port 8500 into the fabio container as well if you're running it like this? Sorry, Docker noob here.

Also, what do the fabio logs say? If they can't get to consul then you should see this:

2017/01/29 20:04:58 [FATAL] Error initializing backend. Get http://localhost:8500/v1/agent/self: dial tcp [::1]:8500: getsockopt: connection refused

Hi Frank, thanks for the response. Adding -p 8500:8500 gives

docker: Error response from daemon: driver failed programming external connectivity on endpoint fabio3 (61a7aa092b0486bc33157b996b52c0c44a22208029d75fa321d953bb8d472a86): Bind for 0.0.0.0:8500 failed: port is already allocated.

8500 is already allocated for Consul.

Not sure if I can access the logs because it looks like they're inside the (would be) container.

You can't map port 8500 into different containers but don't you have to tell fabio where to find consul? It will be looking for localhost:8500 but that would be inside the container. So either you map your external consul endpoint into the container (not sure whether that's even possible) so that localhost:8500 is reachable from within the container or you need to provide -registry.consul.addr <consul ip>:8500 to fabio.

Re logs: a quick search reveals a docker logs <container name> command. That should tell you more.

You've got an update on this?

**docker run -d -p 443:443 -p 9998:9998 magiconair/fabio**

creates a container but exits immediately. docker logs <id> shows

[INFO] Runtime config
{
    "Proxy": {
        "Strategy": "rnd",
        "Matcher": "prefix",
        "NoRouteStatus": 404,
        "MaxConn": 10000,
        "ShutdownWait": 0,
        "DialTimeout": 30000000000,
        "ResponseHeaderTimeout": 0,
        "KeepAliveTimeout": 0,
        "FlushInterval": 1000000000,
        "LocalIP": "172.17.0.3",
        "ClientIPHeader": "",
        "TLSHeader": "",
        "TLSHeaderValue": "",
        "GZIPContentTypes": null
    },
    "Registry": {
        "Backend": "consul",
        "Static": {
            "Routes": ""
        },
        "File": {
            "Path": ""
        },
        "Consul": {
            "Addr": "localhost:8500",
            "Scheme": "http",
            "Token": "",
            "KVPath": "/fabio/config",
            "TagPrefix": "urlprefix-",
            "Register": true,
            "ServiceAddr": ":9998",
            "ServiceName": "fabio",
            "ServiceTags": null,
            "ServiceStatus": [
                "passing"
            ],
            "CheckInterval": 1000000000,
            "CheckTimeout": 3000000000
        }
    },
    "Listen": [
        {
            "Addr": ":9999",
            "Proto": "http",
            "ReadTimeout": 0,
            "WriteTimeout": 0,
            "CertSource": {
                "Name": "",
                "Type": "",
                "CertPath": "",
                "KeyPath": "",
                "ClientCAPath": "",
                "CAUpgradeCN": "",
                "Refresh": 0,
                "Header": null
            },
            "StrictMatch": false
        }
    ],
    "Metrics": {
        "Target": "",
        "Prefix": "{{clean .Hostname}}.{{clean .Exec}}",
        "Names": "{{clean .Service}}.{{clean .Host}}.{{clean .Path}}.{{clean .TargetURL.Host}}",
        "Interval": 30000000000,
        "GraphiteAddr": "",
        "StatsDAddr": "",
        "Circonus": {
            "APIKey": "",
            "APIApp": "fabio",
            "APIURL": "",
            "CheckID": "",
            "BrokerID": ""
        }
    },
    "UI": {
        "Addr": ":9998",
        "Color": "light-green",
        "Title": ""
    },
    "Runtime": {
        "GOGC": 800,
        "GOMAXPROCS": 8
    }
}
2017/02/01 09:08:25 [INFO] Version 1.3.7 starting
2017/02/01 09:08:25 [INFO] Go runtime is go1.7.4
2017/02/01 09:08:25 [INFO] Metrics disabled
2017/02/01 09:08:25 [INFO] Setting GOGC=800
2017/02/01 09:08:25 [INFO] Setting GOMAXPROCS=8
2017/02/01 09:08:25 [FATAL] Error initializing backend. Get http://localhost:8500/v1/agent/self: dial tcp [::1]:8500: getsockopt: connection refused

**docker run -d -p 9999:9999 -p 9998:9998 --link consul magiconair/fabio**
trying to link to the consul container shows

[INFO] Runtime config
{
    "Proxy": {
        "Strategy": "rnd",
        "Matcher": "prefix",
        "NoRouteStatus": 404,
        "MaxConn": 10000,
        "ShutdownWait": 0,
        "DialTimeout": 30000000000,
        "ResponseHeaderTimeout": 0,
        "KeepAliveTimeout": 0,
        "FlushInterval": 1000000000,
        "LocalIP": "172.17.0.3",
        "ClientIPHeader": "",
        "TLSHeader": "",
        "TLSHeaderValue": "",
        "GZIPContentTypes": null
    },
    "Registry": {
        "Backend": "consul",
        "Static": {
            "Routes": ""
        },
        "File": {
            "Path": ""
        },
        "Consul": {
            "Addr": "localhost:8500",
            "Scheme": "http",
            "Token": "",
            "KVPath": "/fabio/config",
            "TagPrefix": "urlprefix-",
            "Register": true,
            "ServiceAddr": ":9998",
            "ServiceName": "fabio",
            "ServiceTags": null,
            "ServiceStatus": [
                "passing"
            ],
            "CheckInterval": 1000000000,
            "CheckTimeout": 3000000000
        }
    },
    "Listen": [
        {
            "Addr": ":9999",
            "Proto": "http",
            "ReadTimeout": 0,
            "WriteTimeout": 0,
            "CertSource": {
                "Name": "",
                "Type": "",
                "CertPath": "",
                "KeyPath": "",
                "ClientCAPath": "",
                "CAUpgradeCN": "",
                "Refresh": 0,
                "Header": null
            },
            "StrictMatch": false
        }
    ],
    "Metrics": {
        "Target": "",
        "Prefix": "{{clean .Hostname}}.{{clean .Exec}}",
        "Names": "{{clean .Service}}.{{clean .Host}}.{{clean .Path}}.{{clean .TargetURL.Host}}",
        "Interval": 30000000000,
        "GraphiteAddr": "",
        "StatsDAddr": "",
        "Circonus": {
            "APIKey": "",
            "APIApp": "fabio",
            "APIURL": "",
            "CheckID": "",
            "BrokerID": ""
        }
    },
    "UI": {
        "Addr": ":9998",
        "Color": "light-green",
        "Title": ""
    },
    "Runtime": {
        "GOGC": 800,
        "GOMAXPROCS": 8
    }
}
2017/02/01 08:49:30 [INFO] Version 1.3.7 starting
2017/02/01 08:49:30 [INFO] Go runtime is go1.7.4
2017/02/01 08:49:30 [INFO] Metrics disabled
2017/02/01 08:49:30 [INFO] Setting GOGC=800
2017/02/01 08:49:30 [INFO] Setting GOMAXPROCS=8
2017/02/01 08:49:30 [FATAL] Error initializing backend. Get http://localhost:8500/v1/agent/self: dial tcp [::1]:8500: getsockopt: connection refused

**docker run -d -p 9999:9999 -p 9998:9998 -p 8500:8500 --link consul magiconair/fabio**
trying to make 8500 available via consul<>host<>fabio gives no docker logs but shows
docker: Error response from daemon: driver failed programming external connectivity on endpoint flamboyant_leavitt (f85bd085108754f63ccadb448a00dd11fbcd131f132c324b0367429d959be01b): Bind for 0.0.0.0:8500 failed: port is already allocated.

Bin On Host Approach
I need a little time to test this.

@digiman999 According to this document docker container linking is deprecated:

https://docs.docker.com/engine/userguide/networking/default_network/dockerlinks/

I'm no docker expert but this sequence of commands starts up fabio with consul in a Docker container. Maybe someone with more experience can comment on this:

docker pull consul
docker pull magiconair/fabio
docker run -d --name=consul -e 'CONSUL_BIND_INTERFACE=eth0' consul
docker logs consul # to get the ip address, in my case 172.17.0.2
docker run -d --name=fabio --link consul -e 'registry_consul_addr=172.17.0.2:8500' magiconair/fabio

I think the default bridge networking bridges the two eth0 interfaces between the containers but that doesn't (shouldn't) work for the lo0 interface. So the way I understand this is that 127.0.0.1 in the consul container is different from 127.0.0.1 in the fabio container since these two interfaces aren't bridged. But again, take all this with a huge grain of salt since I've just skimmed over the Docker networking documentation and augmented this with some assumptions on how networks can/should work.

The Containers have to be within the same docker network.
Here is a docker compose example using the host network https://github.com/raben2/0conf-routing-demo/blob/master/docker-compose.yaml

alternatively you can create a own network for the container stack which allows you to communicate via container name and port.

Since there is no more feedback I'll close this one for now. Please comment if there is something to add and I'll re-open if necessary.

Thanks for this, the environment variable is what really helped me here. I am going to submit a change to the readme.MD with req commands to run docker container.

Um.. you can just run

docker run -p 9999:9999 -p 9998:9998 --net host fabiolb/fabio and it will use the host's network, where the consul port should be available.

Of course, this will work assuming that you don't provision fabio instances dynamically.

Thanks nir0s. I solved that problem many months ago. We are running this in Nomad so docker run is not really relevant...thanks.

Glad to hear. Actually wrote it for future reference..

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shantanugadgil picture shantanugadgil  路  10Comments

erenfro picture erenfro  路  10Comments

alexandruast picture alexandruast  路  4Comments

artyomturkin picture artyomturkin  路  12Comments

scalp42 picture scalp42  路  7Comments