Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker-compose redis: start with fixture?

I am using docker-compose to create a redis container. However, I need it to start with some default key values. Is this possible?

like image 890
Elliot Chance Avatar asked Dec 17 '22 16:12

Elliot Chance


1 Answers

You need to modify your DockerCompose file, You can also add from some file which contains key value but here is the simplest example that adds and get key in DockerCompose file.

version: '2'

services:
  redis:
    image: 'bitnami/redis:latest'
    environment:
      - ALLOW_EMPTY_PASSWORD=yes
    ports:
      - '6379:6379'
    command:
      - /bin/sh
      - -c
      - |
          nohup redis-server &
          sleep 5
          echo "adding some default key value"
          redis-cli SET docker awesome
          echo "Get docker key value"
          redis-cli GET docker
          # this will keep container running
          tail -f /dev/null
like image 176
Adiii Avatar answered Jan 14 '23 06:01

Adiii