title: How to connect to Redis running in Docker container via CLI
body: <p>docker-compose</p>
  
  <pre><code>web:
    container_name: authserver
    restart: always
    build: ./authserver
    expose:
      - "8000"
    links:
      - redis:redis
    environment:
      DEBUG: 'true'
  
  redis:
    restart: always
    image: redis:latest
    ports:
      - "6379:6379"
  </code></pre>
  
  <p>docker inspect authserver_redis_1</p>
  
  <pre><code>    "Gateway": "172.17.0.1",
      "IPAddress": "172.17.0.3",
      "IPPrefixLen": 16,
      "IPv6Gateway": "",
      "GlobalIPv6Address": "",
      "GlobalIPv6PrefixLen": 0,
      "MacAddress": "02:42:ac:11:00:03"
  </code></pre>
  
  <p>From the Python interpreter on my host machine (meaning from where I run docker-compose itself) I can play around with Redis and get/set values </p>
  
  <pre><code>client = redis.StrictRedis(host='172.17.0.3', port=6379, db=0)
  
  client.set("key01", "value01")
  print client.get("key01")
  &gt;&gt;&gt;&gt;"value01"
  </code></pre>
  
  <p>The issue I'm having is that if I run redis-cli from the command line</p>
  
  <pre><code>redis-cli -h 172.17.0.3 -p 6379
  </code></pre>
  
  <p>on the same host machine (the same machine I'm interacting with the Python interpreter on) and then run HGETALL *, I expect to have key01 and value01 returned, but instead it returns</p>
  
  <pre><code>(empty list or set)
  </code></pre>
  
  <p>I had a hard time following both the redis-cli and python redis library docs, so I'm guessing I did some things wrong.</p>