There is little knowledge in this article , Just for the sake of new partners

1. Problem recurrence

Create container

2. Interpretation of parameters

-d:  Background run container , And return to the container ID;

-i:  Run container in interactive mode , Usually associated with -t At the same time ;

-p:  Port mapping , The format is : host ( host ) port : Container port

-t:  Reassign a pseudo input terminal to the container , Usually associated with -i At the same time ;

--ip: Develop a fixed ip

--net: Specify network mode

3. Enter the container to view redis.conf file

No, it turns out redis.conf Document's , Then this is the novice step on the pit stage , Because there is no systematic learning docker So it will take a lot of time


2. solve the problem

What about the lack of configuration files ! That's because redis The configuration file inside the container needs to be mapped in when the container is created

Then we need to delete the container we created before , You need to stop the container before deleting it

Stop container :docker container stop redis-test

Delete container :docker container rm redis-test

1. Start recreating redis container

docker run -itd  --name  redis-slave  -v
/usr/local/redis/redis.conf:/etc/redis.conf -v
/root/usr/local/redis/data:/data  --net mynetwork  -p 6381:6379  --ip  redis

Parameter interpretation :

-v /usr/local/redis/redis.conf:/etc/redis.conf: Mapping profile

-v /root/usr/local/redis/data:/data: Mapping data directory

Then there will be redis Configuration file


Build agreed mount external configuration

It's on my host computer redis In the case of , So the host doesn't have one redis The situation

The mapping here is actually mounting external configuration and data installation

1. establish docker Unified external configuration file

mkdir -p docker/redis/{conf,data}

2. stay conf directories creating redis.conf Configuration file for

touch /docker/redis/conf/redis.conf

3. redis.conf The content of the file needs to be downloaded by yourself , A lot online

4.  Create startup container , Load the configuration file and persist the data

docker run -d --privileged=true -p 6379:6379 -v
/docker/redis/conf/redis.conf:/etc/redis/redis.conf -v /docker/redis/data:/data
--name redis-test redis redis-server /etc/redis/redis.conf --appendonly yes

Parameter description :

--privileged=true: In container root Have real root jurisdiction , Otherwise, in the container root External normal user rights only

-v /docker/redis/conf/redis.conf:/etc/redis/redis.conf: Mapping profile

-v /docker/redis/data:/data: Mapping data directory

redis-server /etc/redis/redis.conf: Specify profile startup redis-server process

--appendonly yes: Enable data persistence

There are also some concepts here. Novices may be confused , It will be explained later , Just know how to use it , It's late at night , Good night everyone. !

©2019-2020 Toolsou All rights reserved,
In the problem of target detection “ recall Recall”,“ Accuracy Precision”Linux Page replacement algorithm C Language implementation About wechat payment body( Product description ) Problems encountered stay Vue Use in Web Worker Calculate the working days of each month c++ Memory Pointer out of bounds detection mechanism _CrtMemBlockHeadeJavaScript Medium Call and Apply Remember once EventBus Project issues caused by memory leaks Hundreds of millions of locusts rarely collide Locusts want to be self driving Heroes Java Swing JList: List box components