< Docker

Try It

Online Free

  1. Use Play with Docker. Create an account and/or log in.
  2. Start an interactive session and add a new instance.
  3. In the terminal window, enter the following commands:
    • docker run -d -p 6379:6379 --name=redis-server redis
    • docker exec -it redis-server hostname -i
      Note the IP address displayed.
  4. To connect to the redis-server from a second instance of the redis image:
    • docker run -it --rm redis bash
    • redis-cli -h 172.17.0.2
      Replace 172.17.0.2 with your redis-server's IP address.
  5. To connect to the redis-server from a programming language in a separate container:
    • Use 172.17.0.2 for the host name.
      Replace 172.17.0.2 with your redis-server's IP address.
    • Modify the Dockerfile to install any required libraries.
  6. To connect to the redis-server from a programming language not running in a container:
    • Use 127.0.0.1 for the host name.
    • Modify the Dockerfile to install any required libraries.

On Your Own System

  1. Install Docker Desktop or the Docker Engine.
  2. In a terminal window, enter the following commands:
    • docker run -d -p 27017:27017 --name=redis-server redis
    • docker exec -it redis-server hostname -i
      Note the IP address displayed.
  3. To connect to the redis-server from a second instance of the redis image:
    • docker run -it --rm redis bash
    • redis-cli -h 172.17.0.2
      Replace 172.17.0.2 with your redis-server's IP address.
  4. To connect to the redis-server from a programming language in a separate container:
    • Use 172.17.0.2 for the host name.
      Replace 172.17.0.2 with your redis-server's IP address.
    • Modify the Dockerfile to install any required libraries.
  5. To connect to the redis-server from a programming language not running in a container:
    • Use 127.0.0.1 for the host name.
    • Modify the Dockerfile to install any required libraries.

See Also

This article is issued from Wikiversity. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.