In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces how to successfully start redis in the docker container and enter, the article is very detailed, has a certain reference value, interested friends must read it!
First of all, you need to search for redis-related mirror sources through docker.
Docker search redis
Then we download the Redis mirror source through Docker
Docker pull redis
If the version is not set up here, the mirror source of latest will be downloaded by default.
[root@localhost ~] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEdocker.io/tomcat latest aeea3708743f 9 days ago 529 MBdocker.io/rabbitmq latest 2b5cda43d345 2 weeks ago 151MBdocker.io/elasticsearch 7.6.0 5d2812e0e41c 2 weeks ago 790 MBdocker.io/redis latest 44d36d2c2374 2 weeks ago 98.2 MBdocker.io/mysql latest 791b6e40940c 2 weeks ago 465 MB [root@localhost ~] #
Then create and start the Redis container
Start Docker first
[root@localhost ~] # systemctl start docker
Start Redis in Docker
Here we do not set an alias for the container, and-d means to launch in the background.
[root@localhost] # docker run-d redisda45019bf760304a66c3dd96b8847a50eddd8c73ff77cd3b3f37a46d7f016834
You can also start Redis in this way, where-p represents a port mapping, mapping 6379 in the container to port 6379 on a machine running Docker, and-- name represents a custom container name
[root@localhost] # docker run-d-p 6379-- name= "myredis" redis249dd65794b32310dea5e094f41df845d971b623382ddc1179c404402f576750 [root@localhost] #
(learn video sharing: redis video tutorial)
Enter the Redis terminal
Docker exec: execute commands in the running container # Syntax docker exec [OPTIONS] CONTAINER COMMAND [ARG...] # OPTIONS description:-d: split mode: run in the background-I: keep STDIN open even if there is no attachment-t: assign a pseudo terminal
The container ID in Docker can be viewed with docker-ps.
[root@localhost ~] # docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES249dd65794b3 redis "docker-entrypoint..." 3 minutes ago Up 3 minutes 0.0.0.0 docker-entrypoint... 6379-> 6379/tcp myredisda45019bf760 redis "docker-entrypoint... "18 minutes ago Up 18 minutes 6379/tcp naughty_ pasteur [root @ localhost ~] #
Redis-cli means to run a redis client.
[root@localhost ~] # docker exec-it da45019bf760 redis-cli127.0.0.1:6379 > 127.0.0.1 Hello World Redis 6379 > set msg "Hello World Redis" OK127.0.0.1:6379 > get msg "Hello World Redis" 127.0.0.1 Hello World Redis 6379 > above is all the contents of the article "how to successfully launch redis and enter it in the redis container". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.