PGBI/kong-dashboard

Error connecting to Kong running within a Docker container

jraj002 opened this issue · 7 comments

Issue summary

I am running a Kong API gateway within a Docker container on a Ubuntu 16.04 machine. I can access the admin port of Kong on port 8001.
I am trying to run the Kong Dashboard within a Docker container and connect to the API gateway.

When I run the following command:
docker run --rm -p 8080:8080 pgbi/kong-dashboard start --kong-url http://localhost:8001/

I get the following error:
Connecting to Kong on http://localhost:8001/ ...
Could not reach Kong on http://localhost:8001/
Error details:
{ Error: connect ECONNREFUSED 127.0.0.1:8001
at Object._errnoException (util.js:1019:11)
at _exceptionWithHostPort (util.js:1041:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1175:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 8001 }

When I run the following command:
docker run --rm -p 8080:8080 pgbi/kong-dashboard start --kong-url http://kong:8001/
I get the following error:
Connecting to Kong on http://kong:8001/ ...
Could not reach Kong on http://kong:8001/
Error details:
{ Error: getaddrinfo ENOTFOUND kong kong:8001
at errnoException (dns.js:53:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:95:26)
code: 'ENOTFOUND',
errno: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'kong',
host: 'kong',
port: '8001' }

Your environment

  • Kong version = 0.12.1
  • Kong Dashboard version = Using the Docker version
  • Node version = #.#.#
  • Npm version = #.#.#

Issue description

Current behavior

Tell us what happens.

Expected behavior

Tell us what should happen instead.

Steps to reproduce

Tell us how to reproduce this issue.

Good to have

Any screenshots? Browsers' logs?

@jraj002 I think, the reason you are getting connection refused error is that your 2 containers (kong and kong-dashboard) are on the default bridge network, which does not do DNS resolution. You need to create a user-defined bridge network and add both the containers to that network. Further reading

Below are the steps that might fix your issue:

  1. Create bridge network
    docker network create my-net
  2. Add Kong container to it
    docker network connect my-net kong
  3. Provide network info when you run kong-dashboard
    docker run --rm --network my-net -p 8080:8080 pgbi/kong-dashboard start --kong-url http://kong:8001

Best,
Peeyush

@peeyush1234 . It worked for me. Thanks.

PGBI commented

Not a Kong-Dashboard bug, more a custom networking configuration one. See https://docs.docker.com/network/

Thanks! Worked for me.

I have this problem too, i already use same docker network bridge , not solve it
[root@vultr ~]# docker run --rm --network my-net -p 8080:8080 pgbi/kong-dashboard start --kong-url http://172.17.0.1:8001
Connecting to Kong on http://172.17.0.1:8001 ...
Could not reach Kong on http://172.17.0.1:8001
Error details:
{ Error: connect EHOSTUNREACH 172.17.0.1:8001
at Object._errnoException (util.js:1019:11)
at _exceptionWithHostPort (util.js:1041:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1175:14)
code: 'EHOSTUNREACH',
errno: 'EHOSTUNREACH',
syscall: 'connect',
address: '172.17.0.1',
port: 8001 }

@dongfangyuxiao I think it is the port 8001 not available out side of kong docker. You can get the result inside the kong docker

If you're following the instructions from the official kong docker instructions a network for kong is already built. All you should need to do is add --network kong-net to the command.

sudo docker run --rm --network kong-net -p 8080:8080 pgbi/kong-dashboard start --kong-url http://kong:8001