I have 2 containers, one for the gateway and one for Redis, as you can see in the docker-compose.yml
file:
tyk_gateway-test:
build: .
ports:
- "8101:8080"
links:
- redis
volumes:
- ./tyk.conf:/opt/tyk-gateway/tyk.conf
- ./apps:/opt/tyk-gateway/apps
extra_hosts:
- "host:192.168.99.1"
redisdata:
image: busybox
volumes:
- /var/lib/redis
redis:
image: redis:latest
ports:
- "8102:6379"
volumes_from:
- redisdata
When I lift the containers, I get the error:
"Connection to Redis failed, reconnect in 10s" err="dial tcp 172.17.0.3:8102: getsockopt: connection refused"
Here’s the configuration of Tyk (tyk.conf
):
{
"listen_port": 8080,
"secret": "<some-secret-that-I-have-hidden-for-the-post>",
"template_path": "/opt/tyk-gateway/templates",
"tyk_js_path": "/opt/tyk-gateway/js/tyk.js",
"use_db_app_configs": false,
"app_path": "/opt/tyk-gateway/apps",
"middleware_path": "/opt/tyk-gateway/middleware",
"storage": {
"type": "redis",
"host": "redis",
"port": 8102,
"username": "",
"password": "",
"database": "2",
"optimisation_max_idle": 500,
"optimisation_max_active": 800
},
...
I am sure the problem is from the host/IP but I don’t know how to approach the problem. I guess it’s because the gateway is trying to find the Redis instance within its container, instead of going outside, to the host machine, and then connecting to the Redis container…
By looking at the /etc/hosts
file of the gateway container I got this info:
So, it sets up Redis to be on that 172.17.0.3
IP… How can I force the gateway too look towards the host machine IP instead?
Any ideas?