Docker’s official redis image specifies the configuration file.

  docker, question

Refer to the use of redis images in docker store.Help

Alternatively, you can specify something along the same lines with docker run options.
$ docker run -v /myredis/conf/redis.conf:/usr/local/etc/redis/redis.conf --name myredis redis redis-server /usr/local/etc/redis/redis.conf
Where /myredis/conf/ is a local directory containing your redis.conf file. Using this method means that there is no need for you to have a Dockerfile for your redis container.

First I created a directory/docker/redis/And put the configuration file in it:redis.conf.

Next, I use the following code to start mirroring:

> docker run -v /docker/redis:/data --name my-redis -d redis redis-server /data/redis.conf

reoccupydocker inspect [containerId]Looking at the container you just created, you found that the container exited immediately after it was started:

"State": {
 "Status": "exited",
 "Running": false,
 "Paused": false,
 "Restarting": false,
 "OOMKilled": false,
 "Dead": false,
 "Pid": 0,
 "ExitCode": 0,
 "Error": "",
 "StartedAt": "2017-02-07T03:15:46.558191922Z",
 "FinishedAt": "2017-02-07T03:15:46.973984747Z"
 },
 ...

In addition, I tried not to specify the configuration file, just hanging it/dataDirectory, there is no problem, can start smoothly:

> docker run -v /docker/redis:/data  -d redis

It seems that we have found the reason. I willredis.confhit the targetdaemonize yesComment out and run! But what is the reason?

docker-entrypoint.sh

#!  /bin/sh
 set -e
 
 # first arg is `-f` or `--some-option`
 # or first arg is `something.conf`
 if [ "${1#-}" !  = "$1" ] || [ "${1%.conf}" !  = "$1" ];  then
 set -- redis-server "$@"
 fi
 
 # allow the container to be started with `--user`
 if [ "$1" = 'redis-server' -a "$(id -u)" = '0' ];  then
 chown -R redis .
 exec gosu redis "$0" "$@"
 fi
 
 exec "$@"

The above is the official redis mirror entrypoint script, shell script does not understand, check the first lineset -eIt means:"If the command return value is not equal to 0, exit the shell immediately."Is it related to this? Or withdocker runThe-dAre the parameters relevant?"Run container in background and print container ID"

This is how mine started

docker run -d -ti \
 -p 7481:6379 \
 -v /project/pos/conf/redis.conf:/etc/redis/redis.conf \
 -v /project/pos/data:/data \
 --restart always \
 --name pos_redis \
 daocloud.io/redis \
 redis-server /etc/redis/redis.conf