mirror of
https://github.com/marcel-dempers/docker-development-youtube-series.git
synced 2025-06-06 17:01:30 +00:00
67 lines
1.4 KiB
Markdown
67 lines
1.4 KiB
Markdown
# Redis
|
|
|
|
## Docker
|
|
|
|
Docker image over [here](https://hub.docker.com/_/redis)
|
|
|
|
## Running redis
|
|
|
|
```
|
|
docker network create redis
|
|
docker run -it --rm --name redis --net redis redis:6.0-alpine
|
|
```
|
|
|
|
## Configuration
|
|
|
|
Redis configuration documentation [here](https://redis.io/topics/config)
|
|
|
|
Starting Redis with a custom config
|
|
|
|
```
|
|
cd .\storage\redis\
|
|
docker run -it --rm --name redis --net redis -v ${PWD}/config:/etc/redis/ redis:6.0-alpine redis-server /etc/redis/redis.conf
|
|
|
|
```
|
|
|
|
## Redis client application
|
|
|
|
An example application that reads a key from Redis, increments it and writes it back to Redis.
|
|
|
|
```
|
|
cd .\storage\redis\applications\client\
|
|
|
|
docker build . -t aimvector/redis-client:v1.0.0
|
|
|
|
# start go dev environment
|
|
docker run -it -v ${PWD}:/go/src -w /go/src --net redis -p 80:80 aimvector/redis-client:v1.0.0
|
|
|
|
# go build client.go
|
|
|
|
```
|
|
|
|
Run our application
|
|
|
|
```
|
|
docker build . -t aimvector/redis-client:v1.0.0
|
|
docker run -it --net redis `
|
|
-e REDIS_HOST=redis `
|
|
-e REDIS_PORT=6379 `
|
|
-e REDIS_PASSWORD="SuperSecretSecureStrongPass" `
|
|
-p 80:80 `
|
|
aimvector/redis-client:v1.0.0
|
|
|
|
```
|
|
|
|
## Persistence
|
|
|
|
Redis Persistence Documentation [here](https://redis.io/topics/persistence)
|
|
|
|
|
|
```
|
|
docker volume create redis
|
|
cd .\storage\redis\
|
|
docker run -it --rm --name redis --net redis -v ${PWD}/config:/etc/redis/ -v redis:/data/ redis:6.0-alpine redis-server /etc/redis/redis.conf
|
|
|
|
```
|
|
|
|
## Security! |