Remote Redis Servers for Development
By Justin

Using Virtual Machines for Redis during Development
In this guide, I am going to show you how to run a remote Redis server in nearly any virtual machine. The goal is to do as little as possible in configuring our instance while gaining all the benefits of using a near production-ready instance of Redis.
Step 1. Boot up a Virtual Machine on Linode
Navigate to https://cloud.linode.com/linodes/create
Add the minimum spec:
- Shared CPU > 1GB (approx $5/mo)
- Ubuntu 18 LTS+ or Debian 11+
- Use a location near your physical location (e.g. Seattle (us-sea) if you live in Idaho like me)
- Ensure you install your local computer's SSH keys during creation
Step 2. SSH into your Virtual Machine
Replace 23.239.0.131 with your IP Address
Such as ssh [email protected]
Step 3. Install Docker
This is by far the easiest way to install docker on a virtual machine.
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
Step 4: Create the Docker Compose File
Just like in this short, we'll use Docker Compose to manage our Redis instance like:
bash
touch ~/compose.yaml
yaml
version: '3.9'
services:
redis:
image: redis
restart: always
ports:
- 6379:6379
volumes:
- redis_data:/data
entrypoint: redis-server --appendonly yes
volumes:
redis_data:
networks:
default:
name: redis_network
The key part to remember in Docker and Docker compose is how ports work. In this case 6379:6379 the localhost port is mapped to the internal container port. In other words, the virtual machine can be connected to via localhost:<first-port> or localhost:6379. If you need to change any port value, change the first one <first-port>:<second-port>. When it doubt, don't change either or learn more about Docker Compose port mapping.
Step 5. Run Docker Compose
cd ~/
docker compose -f compose.yaml up -d
The keys are:
- docker is installed
- docker compose is a way to run multiple containers via manifest declrations as in our compose.yaml from above.
- -f compose.yaml just a way to reference which Docker compose file
- up to bring the services listed in the compose file up.
- -d means all of your docker compose services will run in the background automatically. In our case restart:always is listed in the compose file for Redis so if the virtual machine needs to restart, it will automatically thanks to Docker Compose.
Step 6. Verify Redis Locally or Anywhere
redis-cli -h 23.239.0.131 ping
Once again 23.239.0.131 with your IP Address
- redis-cli is the standard Redis command line tool. You can also use Python to connect to Redis and many other languages.
- ping is a simple command to ping the Redis server to verify it's running.
Assuming we did everything correctly, you should see PONG.
Personally, I rarely use this method to deploy a Redis instance for development. I almost always use Docker Compose locally or port forward a Redis Statefulset on Kubernetes. This method is very useful if you are not interested in learning Docker or Kubernetes or you are stuck with a computer (Windows cough cough) that does not have native support for Redis.
Now that you have a Redis instance, it's time to integrate Django + Celery.