简体   繁体   中英

creating a redis docker container with an exising rdb and load module at initiation?

I am trying to start a docker container using a redis db that I have a persistent copy saved to a local machine. I currently have a docker container loading redis with a volume using this docker-compose.yml but it misses my redis.conf (which contains the loadmodule command) is located in the volume with the rdb file

version: '3'
services:
  redis:
    image: redis
    container_name: "redis"
    ports:
      - "6379:6379"
    volumes:
      - E:\redis_backup_conf:/data

This begins to load the RDB but crashes out because the data uses this time series module.

I can load a seperate docker container with a fresh redis db that has the time seriese module loaded using the following dockerfile. My issue is I can't figure out how to do both at the same time!

Is there someway of calling a dockerfile from a docker-compose.yml or declaring the volume in the dockerfile? That, or should I be creating my own image that I can call in the docker-compose.yml? Any help woule be appreciated, I'm honeslty just going round in circles I think.

dockerfile

# BUILD redisfab/redistimeseries:${VERSION}-${ARCH}-${OSNICK}

ARG REDIS_VER=6.0.1

# stretch|bionic|buster
ARG OSNICK=buster

# ARCH=x64|arm64v8|arm32v7
ARG ARCH=x64

#----------------------------------------------------------------------------------------------
FROM redisfab/redis:${REDIS_VER}-${ARCH}-${OSNICK} AS builder

ARG REDIS_VER

ADD ./ /build
WORKDIR /build

RUN ./deps/readies/bin/getpy2
RUN ./system-setup.py
RUN make fetch
RUN make build

#----------------------------------------------------------------------------------------------
FROM redisfab/redis:${REDIS_VER}-${ARCH}-${OSNICK}

ARG REDIS_VER

ENV LIBDIR /usr/lib/redis/modules
WORKDIR /data
RUN mkdir -p "$LIBDIR"

COPY --from=builder /build/bin/redistimeseries.so "$LIBDIR"

EXPOSE 6379
CMD ["redis-server", "--loadmodule", "/usr/lib/redis/modules/redistimeseries.so"]

EDIT:

ok.. slight improvement i can call a redis-timeseries image in the docker-compose.yml

services:
  redis:
    image: redislabs/redistimeseries
    container_name: "redis"
    ports:
      - "6379:6379"
    volumes:
      - E:\redis_backup_conf:/data

This is a start however I still need to increase the maximum number of db's, I have been using the redis.conf to do this in the past.

You can just have docker-compose build your dockerfile directly. Assume your docker-compose file is in folder called myproject. Also assume your dockerfile is in a folder called myredis and that myredis is in the myproject folder. Then you can replace this line in your docker-compose file:

Image: redis

With:

Build: ./myredis

That will build and use your custom image

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM