Quickstart
Create a new app
Go to the bunny.net dashboard, select Magic Containers, and click Add App. Select Single region deployment.
Add the Redis container
Click Add Container and configure the image:
- Registry: Docker Hub
- Image:
library/redis - Tag:
7-alpine
Add a persistent volume
In the Volumes section of the container settings, add a volume:
- Name:
redis-data - Mount path:
/data
Redis has no authentication enabled by default. It’s recommended to set a
password even if Redis is not exposed externally. Other containers in the same
pod can access the network. Set a password by configuring the container
command to
redis-server --requirepass YOUR_PASSWORD, and update your
connection string to redis://:YOUR_PASSWORD@127.0.0.1:6379.Redis uses
/data as its default data directory. The official image is
configured to use append-only file (AOF) persistence by default, which writes
every operation to disk in the mounted volume.Connect from your app
In a multi-container setup, your app and Redis share the same localhost network. Connect using127.0.0.1 and the default port 6379.
- Connection string
- Node.js
- Go
- Python
- PHP
Multi-container example
A typical setup pairs Redis with your application. When configuring the app, add two containers:App container
- Image: your app image (e.g.
ghcr.io/<your-username>/my-app:latest) - Endpoint: the port your app listens on
- Environment variables:
REDIS_URL=redis://127.0.0.1:6379
Redis container
- Image:
library/redis:7-alpine - Volume: mount path
/data
Both containers share the same localhost network, so your app connects to
Redis at
127.0.0.1:6379. See multi-container
apps for more details.External access
To connect to Redis from outside Magic Containers (e.g. from your local terminal), add an Anycast endpoint:- Go to your app’s Endpoints tab and click Add New Endpoint
- Select Anycast as the type
- Set Container Port to
6379 - Set Exposed Port to
6379 - Click Add Endpoint
The exposed port and container port may differ. When connecting externally,
always use the exposed port shown in your endpoint configuration.