1、安装docker-ce
1)
[root@localhost ~]# docker --version #查询安装版本
Docker version 20.10.17, build 100c701
2)
[root@localhost ~]# docker version #显示版本信息
Client: Docker Engine - Community
Version: 20.10.17
API version: 1.41
Go version: go1.17.11
Git commit: 100c701
Built: Mon Jun 6 23:05:12 2022
OS/Arch: linux/amd64
Context: default
Experimental: trueServer: Docker Engine - Community
Engine:
Version: 20.10.17
API version: 1.41 (minimum version 1.12)
Go version: go1.17.11
Git commit: a89b842
Built: Mon Jun 6 23:03:33 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.7
GitCommit: 0197261a30bf81f1ee8e6a4dd2dea0ef95d67ccb
runc:
Version: 1.1.3
GitCommit: v1.1.3-0-g6724737
docker-init:
Version: 0.19.0
GitCommit: de40ad0
3)
[root@localhost ~]# 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 bashShare 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/
4)
[root@localhost ~]# docker run -it ubuntu bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
d19f32bd9e41: Pull complete
Digest: sha256:34fea4f31bf187bc915536831fd0afc9d214755bf700b5cdb1336c82516d154e
Status: Downloaded newer image for ubuntu:latest
root@aa768a5a7021:/#
2.下载并查看镜像
1)
[root@localhost ~]# docker pull nginx #下载nginx的镜像
Using default tag: latest
latest: Pulling from library/nginx
1efc276f4ff9: Already exists
baf2da91597d: Already exists
05396a986fd3: Pulling fs layer
6a17c8e7063d: Downloading 658B/891B #下载实在太慢
27e0d286aeab: Waiting
2)
[root@localhost ~]# docker pull alpine #下载alpine的镜像
Using default tag: latest
latest: Pulling from library/alpine
213ec9aee27d: Already exists
Digest: sha256:bc41182d7ef5ffc53a40b044e725193bc10142a1243f395ee852a8d9730fc2ad
Status: Downloaded newer image for alpine:latest
docker.io/library/alpine:latest
3)
[root@localhost ~]# docker pull httpd #下载httpd的镜像
Using default tag: latest
latest: Pulling from library/httpd
Digest: sha256:343452ec820a5d59eb3ab9aaa6201d193f91c3354f8c4f29705796d9353d4cc6
Status: Image is up to date for httpd:latest
docker.io/library/httpd:latest
[root@localhost ~]# docker images | grep httpd #查看httpd的镜像
httpd latest f2a976f932ec 2 weeks ago 145MB
[root@localhost ~]# docker tag httpd test/httpd:v1 #给httpd的镜像打标签
[root@localhost ~]# docker images | grep httpd
httpd latest f2a976f932ec 2 weeks ago 145MB
test/httpd v1 f2a976f932ec 2 weeks ago 145MB