Redis学习笔记
运行环境
本机环境是windows装配wsl,在wsl内装配了docker,在docker内运行redis
简单的docker知识
使用windows-terminal启动wsl
启动wsl:
PS C:\Users\末小七> wsl
mirana@末小七:/mnt/c/Users/末小七$
运行docker
mirana@末小七:/mnt/c/Users/末小七$ sudo service docker start
[sudo] password for mirana:
* Starting Docker: docker
查看本地所有镜像
mirana@末小七:/mnt/c/Users/末小七$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> db7ee0dd2158 15 hours ago 162MB
<none> <none> 5eaae8aec40b 15 hours ago 162MB
nginx latest ad4c705f24d3 33 hours ago 133MB
redis latest 02c7f2054405 7 days ago 105MB
mysql latest 0716d6ebcc1a 7 days ago 514MB
hello-world latest d1165f221234 6 months ago 13.3kB
java openjdk-8-jdk-alpine 3fd9dd82815c 4 years ago 145MB
删除镜像
为了展示下一步下载镜像 先把hello-world镜像删除
坑:
如果直接使用rmi删除hello-world镜像,会报这个错。
因为之前运行过这个镜像,所以已经创建了这个镜像的容器,在删除镜像前,要把容器也删除
mirana@末小七:/mnt/c/Users/末小七$ docker rmi hello-world
Error response from daemon: conflict: unable to remove repository reference "hello-world" (must force) - container ef9c2ed05561 is using its referenced image d1165f221234
先查看docker内所有的镜像,获取hello-world这个镜像的镜像id
mirana@末小七:/mnt/c/Users/末小七$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> db7ee0dd2158 15 hours ago 162MB
<none> <none> 5eaae8aec40b 15 hours ago 162MB
nginx latest ad4c705f24d3 33 hours ago 133MB
redis latest 02c7f2054405 7 days ago 105MB
mysql latest 0716d6ebcc1a 7 days ago 514MB
hello-world latest d1165f221234 6 months ago 13.3kB
java openjdk-8-jdk-alpine 3fd9dd82815c 4 years ago 145MB
然后查看docker内所有的容器 -a是没运行的也要展示
mirana@末小七:/mnt/c/Users/末小七$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b4c36f8ea3d5 hello-world "/hello" 4 minutes ago Exited (0) 4 minutes ago nostalgic_ganguly
3bfc98b3236f redis "docker-entrypoint.s…" 37 minutes ago Exited (0) 18 minutes ago myredis
5f2877114e4f db7ee0dd2158 "java -Djava.securit…" 15 hours ago Exited (143) 15 hours ago spring-boot
06b2550f05c9 nginx "/docker-entrypoint.…" 16 hours ago Exited (0) 16 hours ago optimistic_stonebraker
不加-a是只展示正在运行的容器
mirana@末小七:/mnt/c/Users/末小七$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
rm是移除容器
rmi是移除镜像
mirana@末小七:/mnt/c/Users/末小七$ docker rm b4c36f8ea3d5
b4c36f8ea3d5
mirana@末小七:/mnt/c/Users/末小七$ docker rmi d1165f221234
Untagged: hello-world:latest
Untagged: hello-world@sha256:7d91b69e04a9029b99f3585aaaccae2baa80bcf318f4a5d2165a9898cd2dc0a1
Deleted: sha256:d1165f2212346b2bab48cb01c1e39ee8ad1be46b87873d9ca7a4e434980a7726
Deleted: sha256:f22b99068db93900abe17f7f5e09ec775c2826ecfe9db961fea68293744144bd
再次查看,已经没有hello-world镜像了
mirana@末小七:/mnt/c/Users/末小七$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> db7ee0dd2158 2 days ago 162MB
<none> <none> 5eaae8aec40b 2 days ago 162MB
nginx latest ad4c705f24d3 3 days ago 133MB
zookeeper latest 2a33b1a1e11a 8 days ago 278MB
redis latest 02c7f2054405 9 days ago 105MB
mysql latest 0716d6ebcc1a 9 days ago 514MB
hello-world latest d1165f221234 6 months ago 13.3kB
java openjdk-8-jdk-alpine 3fd9dd82815c 4 years ago 145MB
下载镜像
在docker容器中查找hello-world镜像
mirana@末小七:/mnt/c/Users/末小七$ docker search hello-world
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
hello-world Hello World! (an example of minimal Dockeriz… 1522 [OK]
kitematic/hello-world-nginx A light-weight nginx container that demonstr… 150
tutum/hello-world Image to test docker deployments. Has Apache… 84 [OK]
dockercloud/hello-world Hello World! 19 [OK]
crccheck/hello-world Hello World web server in under 2.5 MB 15 [OK]
in28min/hello-world-rest-api 9
vad1mo/hello-world-rest A simple REST Service that echoes back all t… 5 [OK]
arm32v7/hello-world Hello World! (an example of minimal Dockeriz… 3
ppc64le/hello-world Hello World! (an example of minimal Dockeriz… 2
souravpatnaik/hello-world-go hello-world in Golang 1
ansibleplaybookbundle/hello-world-apb An APB which deploys a sample Hello World! a… 1 [OK]
ansibleplaybookbundle/hello-world-db-apb An APB which deploys a sample Hello World! a… 1 [OK]
thomaspoignant/hello-world-rest-json This project is a REST hello-world API to bu… 1
datawire/hello-world Hello World! Simple Hello World implementati… 1 [OK]
infrastructureascode/hello-world A tiny "Hello World" web server with a healt… 0 [OK]
strimzi/hello-world-producer 0
strimzi/hello-world-streams 0
businessgeeks00/hello-world-nodejs 0
koudaiii/hello-world 0
burdz/hello-world-k8s To provide a simple webserver that can have … 0 [OK]
nirmata/hello-world 0 [OK]
strimzi/hello-world-consumer 0
freddiedevops/hello-world-spring-boot 0
garystafford/hello-world Simple hello-world Spring Boot service for t… 0 [OK]
kevindockercompany/hello-world 0
在docker仓库中pull下hello-world镜像,:后是版本号,默认latest->最新
mirana@末小七:/mnt/c/Users/末小七$ docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
Digest: sha256:7d91b69e04a9029b99f3585aaaccae2baa80bcf318f4a5d2165a9898cd2dc0a1
Status: Image is up to date for hello-world:latest
docker.io/library/hello-world:latest
在docker内运行hello-world
mirana@末小七:/mnt/c/Users/末小七$ docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
over