Elliot Chance
Elliot Chance

Reputation: 5746

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?

Upvotes: 4

Views: 2339

Answers (1)

Adiii
Adiii

Reputation: 60084

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

Upvotes: 8

Related Questions