Follow

$ docker --version
Docker version 20.10.12, build 20.10.12-0ubuntu4
$ docker run -it c92e3dc29000
root@fb45221ab9cd:/app# irb
irb(main):001:0> require 'redis'
irb(main):002:0> r=Redis.new
=> #<Redis client v4.7.1 for redis://host.docker.internal:6379/0>

お!!

irb(main):003:0> r.ping
Traceback (most recent call last):
:
Redis::CannotConnectError (Error connecting to Redis on host.docker.internal:6379 (SocketError))

ありゃー

· · Web · 1 · 0 · 1

ホストではサーバ走ってるんだけどねー

$ bundle exec irb
irb(main):001:0> require 'redis'
irb(main):002:0> r=Redis.new
=> #<Redis client v4.7.1 for redis://127.0.0.1:6379/0>
irb(main):003:0> r.ping
=> "PONG"

Dockerfileから見てたのかな

ENV REDIS_URL=${REDIS_URL:-redis://host.docker.internal:6379}

この行を消した子だと

$ docker run -it aef27f97f96c
root@8ee1bb005b2e:/app# irb
irb(main):001:0> require 'redis'
irb(main):002:0> r=Redis.new
=> #<Redis client v4.7.1 for redis://127.0.0.1:6379/0>
irb(main):003:0> r.ping
:
Redis::CannotConnectError (Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED))

うん。

Sign in to participate in the conversation
zundon

Zundon is a single user instance as home of @zundan as well as a test bed for changes of the code.