Not only teach you to install, but also teach you to delete.
Each line of command is illustrated, which is absolutely understandable.
Command: docker search < image name >
docker search redis
You can see that there are many redis images. Since there is no version specified here, the default latest version is downloaded.redis latest.
Command:: docker pull < image name >: < version number >
docker pull redis
The next step is to mount the redis configuration file toStart redis container in profile mode。(Mount: that is, the host file is associated with the internal directory of the container and bound to each other. If the file is modified in the host, the internal file of the container is also modified)
1) . mount the redis configuration file
2) . mount the persistent file of redis (for data persistence).
My profile is placed in
Redis.com under liunx Conf file location: / home / redis / myredis / redis conf
Redis data file location under liunx: / home / redis / myredis / data
You can choose the location by yourself
mkdir -p /home/redis/myredisIf the command does not exist, directly create the / home / redis / myredis folder
myredis. I uploaded conf manually. (the file is at the end of the text, and the standard file of redis.conf can also be found on the official website of redis)
docker run --restart=always --log-opt max-size=100m --log-opt max-file=2 -p 6379:6379 --name myredis -v /home/redis/myredis/myredis.conf:/etc/redis/redis.conf -v /home/redis/myredis/data:/data -d redis redis-server /etc/redis/redis.conf --appendonly yes --requirepass 000415
- – restart = always always
- – log is the of log
- -P 6379: 6379 mount port 6379 out
- – name give the container a name
- -V data volume mount
- /home/redis/myredis/myredis. conf:/etc/redis/redis. Conf here is myredis. Conf under the liunx path Redis under conf and redis Conf is mounted together.
- /Home / redis / myredis / data: / data is the same as above
- -D redis means that redis is started in the background
- redis-server /etc/redis/redis. Conf starts redis with the configuration file, loads the conf file in the container, and finally finds the mounted directory / etc / redis / redis Conf alsoIt’s / home / redis / myredis / myredis under liunx conf
- – appendonly yes enable redis persistence
- – requirepass 000415 set password(if you are connected inside the docker container, you can set it or not. But if you want to open it to the outside world, you must set it. I’ve been engaged in it, so you can read this article“Alibaba cloud server poisoning ‘kirito666’ experience”）
- Successful interface
Docker PS - a | grep myredis # check the startup status through the docker PS command to see if it is successful
Command: docker logs — since 30m < container name >
Here — since 30m is to view the log of this container within 30 minutes.
docker logs --since 30m myredis
Command: docker exec – it < container name > / bin / Bash
The redis cli followed here is to directly input the command on it.
docker exec -it myredis redis-cli
After entering, I directly enter the view command:
Error is no permission verification.
(because the password is set.)
Check whether the current redis password is set:
(it can only be entered after passing the verification)
config get requirepass
# bind 192.168.1.100 10.0.0.1 # bind 127.0.0.1 ::1 #bind 127.0.0.1 protected-mode no port 6379 tcp-backlog 511 requirepass [email protected] timeout 0 tcp-keepalive 300 daemonize no supervised no pidfile /var/run/redis_6379.pid loglevel notice logfile "" databases 30 always-show-logo yes save 900 1 save 300 10 save 60 10000 stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename dump.rdb dir ./ replica-serve-stale-data yes replica-read-only yes repl-diskless-sync no repl-disable-tcp-nodelay no replica-priority 100 lazyfree-lazy-eviction no lazyfree-lazy-expire no lazyfree-lazy-server-del no replica-lazy-flush no appendonly yes appendfilename "appendonly.aof" no-appendfsync-on-rewrite no auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb aof-load-truncated yes aof-use-rdb-preamble yes lua-time-limit 5000 slowlog-max-len 128 notify-keyspace-events "" hash-max-ziplist-entries 512 hash-max-ziplist-value 64 list-max-ziplist-size -2 list-compress-depth 0 set-max-intset-entries 512 zset-max-ziplist-entries 128 zset-max-ziplist-value 64 hll-sparse-max-bytes 3000 stream-node-max-bytes 4096 stream-node-max-entries 100 activerehashing yes hz 10 dynamic-hz yes aof-rewrite-incremental-fsync yes rdb-save-incremental-fsync yes
After teaching you how to load, we have to learn how to unload, otherwise we can’t become skilled workers (manual dog head)
View all running containers:
docker ps -a
Stop command:Docker stop < container name >
Docker stop myredis # myredis is named after I started redis
Delete redis container:
Delete container command:Docker RM < container name >
docker rm myredis
After deleting the container, we begin to delete itRedis image。
View all mirror commands:
Delete mirror commandDocker RMI < container ID >
Docker RMI 739b59b96069 # this is my image redis ID
You can see that the redis image has been deleted.
I downloaded it last time, but because there was no record, I had to check it again. Finally, I wrote this article
FuckDocker installs redisBlog, hope to help you.