Redis installation, start, stop, and delete operations on docker

Find Mirror
Search for images by name

docker search redis
searches by name and displays non-truncated descriptions (–no-trunc)

docker search --stars=3 --no-trunc
redis searches for mirrors with at least 3 stars by name redis

docker search --filter stars=3 redis
displays images with "redis" in the name, and is automatically built


The image name displayed by docker search --filter is-automated redis contains "redis", has at least 3 stars, and is the official version

$ docker search --filter "is-official=true" --filter "stars=3" redis
format option (--format) uses Go templates to beautifully print the search output.

1. Use the template without header, Name and StarCount to output colon-separated entries and entries for all images:
docker search --format "{ {.Name}}:{ {.StarCount}}" redis
2. Output table Format:
docker search --format “table { {.Name}}\t{ {.IsAutomated}}\t{ {.IsOfficial}}" redis
pull image If
no version is specified, pull the latest version of the image

docker pull redis
specified version

docker pull redis: 5.0.5
View the successfully pulled image
docker images
start image and parameter description
docker run --name redis -p 6379:6379 --restart=always -v $PWD/data:/data -d redis:5.0 .5 redis-server --appendonly yes daemonize yes
parameter description: #local
run-
d #local
port:Docker port
6379:6379 #specified
drive disk-
v
#Redis persistent file storage
$PWD/data
#docker image name
Redis
#redis server
Redis-server
# open persistence
-appendonly yes
# this operation mirrors the name
-name
# daemon
daemonize yes
#Docker start container starts
-restart = always
stop running in front of a mirror set (redis as a mirror image Name)
docker stop redis
delete mirror
docker rm redis
Restart the image
docker start redis to
obtain the container ID or name
docker container ls -a
If the container you want to delete is still running, stop the
container first: docker container stop CONTAINER_ID
delete the specified container
docker container rm CONTAINER_ID or docker container rm CONTAINER_NAME (both
commands delete the same container)
Obtain container IDs in batch
docker container ls -a -q
Obtain image IDs in batch
docker image ls -a -q
Stop containers in batch
docker container stop $(docker container ls -a -q )
Deleting containers in
batches docker container rm $(docker container ls -a -q)
Specify the image to be deleted by the id of the image
docker rmi
If you want to delete the untagged images, that is, the image with the id, you can use
docker rmi $(docker images | grep “^” | awk “{print $3}”)
To delete all images
docker rmi $(docker images -q) to
access the container
docker exec -it redis bash
Use redis-cli to access redis in the container
docker exec -it redis redis-cli
Reprint: https://blog.csdn.net/l1028386804/article/details /105682096

Guess you like

Origin blog.csdn.net/weixin_42118981/article/details/112975707