< Docker
Try It
Online Free
- Use Play with Docker. Create an account and/or log in.
- Start an interactive session and add a new instance.
- 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.
- 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
Replace172.17.0.2
with your redis-server's IP address.
- To connect to the redis-server from a programming language in a separate container:
- Use
172.17.0.2
for the host name.
Replace172.17.0.2
with your redis-server's IP address. - Modify the
Dockerfile
to install any required libraries.
- Use
- 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.
- Use
On Your Own System
- Install Docker Desktop or the Docker Engine.
- 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.
- 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
Replace172.17.0.2
with your redis-server's IP address.
- To connect to the redis-server from a programming language in a separate container:
- Use
172.17.0.2
for the host name.
Replace172.17.0.2
with your redis-server's IP address. - Modify the
Dockerfile
to install any required libraries.
- Use
- 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.
- Use
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.