I am running my “golang” and redis service using docker. my application config file is
database:
engine: "mysql"
username: "root"
password: ""
host: "127.0.0.1"
port: "3306"
db: "dummy_db"
cache:
engine : "redis"
host : "redis"
# host : "127.0.0.1"
port : "6379"
db : 1
maxconn : 10
and my docker-compose file is
goApp:
build:
context: .
dockerfile: goApp/Dockerfile
image: goApp
container_name: goApp-apis
restart: always
working_dir: /go/src/goApp
depends_on:
- "redis"
ports:
- '9090:9090'
network_mode: "host"
entrypoint: ["/entrypoint.sh"]
command: ["apis"]
redis:
image: redis
container_name: redis
restart: always
ports:
- '6379:6379'
volumes:
- './volumes/redis-data:/data'
In my host machine redis is not installed.
From my application i want to access my host machine mysql and redis from docker.
To connect with my host machine i am using network_mode=host
or network_mode=bridge
. with this mysql connection is successful… but not able to connect with redis.
if i removed network_mode
then redis connection is successful …but not able to connect with mysql.
So please suggest me how i can access mysql from host machine and redis from docker container.
Thanks in advance.