Networking between Docker containers
Docker actually provides DNS support for networking between containers. This means that if you define your database connection as:

http://redis:6379


This will resolve redis to the correct network address, given that you fulfill the following:


All containers are on the same network
The containers have been named


This can either be done manually by starting both instances via the cli or automated with a docker compose script, which is my recommendation. In the compose script, from version 3, you would define the both services (aka the containers):

version: "3"
services:
  web:
    build: ./web
    container_name: web
    networks:
      - backend
    command: bash -c "./start.sh"

  redis:
    image: redis:3.2
    container_name: redis
    networks:
      - backend


And at the end of the file, define the network both instances should be connected to:

networks:
  backend: