欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

docker的常用命令(一)

程序员文章站 2022-04-19 08:53:13
...

还是先丢出官方的文档,学东西还是尽可能的看官方的文档,但是说真的看这个东西吧,又有点看不动,但是还是尽力的看!
docker的常用命令(一)
地址:

https://docs.docker.com/reference/

好了,我来说说一些基本的比较常用的命令,我们先来入个门,等到学的差不多了,在看官方的这个文档,就会好很多!

1.镜像基本命令

查看镜像

docker images   #查看镜像

我们也可以在后面跟一个 --help来查看它后面可以跟的一些参数,我这里就不弄了

[aaa@qq.com ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              fce289e99eb9        16 months ago       1.84kB
# 列出所有的镜像,这个是上次安装docker时测试用的hello-word的镜像
REPOSITORY        镜像的仓库源
TAG               镜像的标签(版本,latest最新版本)
IMAGE ID          镜像的id(想想自己的身份证号)
CREATED           创建时间
SIZE              大小

搜索镜像

docker search 镜像名    # 搜索镜像

这个命令表达的就是这个意思:
docker的常用命令(一)
地址:

https://hub.docker.com/

docker的常用命令(一)
下载镜像

docker pull mysql

不指定就是下载最新的:
docker的常用命令(一)
常用的是下载指定版本的:

[aaa@qq.com ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mysql               latest              94dff5fab37f        3 days ago          541MB
hello-world         latest              fce289e99eb9        16 months ago       1.84kB
[aaa@qq.com ~]# docker pull mysql:5.7
5.7: Pulling from library/mysql
afb6ec6fdc1c: Already exists 
0bdc5971ba40: Already exists 
97ae94a2c729: Already exists 
f777521d340e: Already exists 
1393ff7fc871: Already exists 
a499b89994d9: Already exists 
7ebe8eefbafe: Already exists 
4eec965ae405: Pull complete 
a531a782d709: Pull complete 
10e94c02b508: Pull complete 
799a94b968ef: Pull complete 
Digest: sha256:5c9fd7949bc0f076429fa2c40d0e7406e095bdb5216a923257b31972a6f3ae4f
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7

删除镜像

使用docker rmi 删除,后面跟参数,告诉ta怎么删,删哪里的:
docker rmi -f id(前面提到的像你的身份证的一样的东西)
docker rmi -f  id id id id ...删除多个
docker rmi -f $(docker images -aq) 删干净 
[aaa@qq.com ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mysql               5.7                 b84d68d0a7db        3 days ago          448MB
mysql               latest              94dff5fab37f        3 days ago          541MB
hello-world         latest              fce289e99eb9        16 months ago       1.84kB
[aaa@qq.com ~]# docker rmi -f fce289e99eb9
Untagged: hello-world:latest
Untagged: aaa@qq.com:f9dfddf63636d84ef479d645ab5885156ae030f611a56f3a7ac7f2fdd86d7e4e
Deleted: sha256:fce289e99eb9bca977dae136fbe2a82b6b7d4c372474c9235adc1741675f587e
[aaa@qq.com ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mysql               5.7                 b84d68d0a7db        3 days ago          448MB
mysql               latest              94dff5fab37f        3 days ago          541MB
[aaa@qq.com ~]# docker rmi -f $(docker images -aq)
Untagged: mysql:5.7
Untagged: aaa@qq.com:5c9fd7949bc0f076429fa2c40d0e7406e095bdb5216a923257b31972a6f3ae4f
Deleted: sha256:b84d68d0a7db79194091fae58b71afb6a56ae25cb297e91f68db2a8e404a4ecb
Deleted: sha256:94e95e9df0df22878f59564132685bcef12c08e0c4b390827ba321829be6e7b6
Deleted: sha256:6a618a3ef5f57ced96e11f6c01eb9760bdd225fccb98365f696fbc7298129fec
Deleted: sha256:7d0236d50948d993a686c69889c6f016a8da89b8557c5e0eaf6af145ea5877cb
Deleted: sha256:a6219b1270405f43892a7a12895ae1e0ccff307d162cf0025df3ed87f511754b
Untagged: mysql:latest
Untagged: aaa@qq.com:beba993cc5720da07129078d13441745c02560a2a0181071143e599ad9c497fa
Deleted: sha256:94dff5fab37f18946165632a45d8ff738ee97dc7a9dfde945b0862d52ecc5b08
Deleted: sha256:dc323e8164e71563f2a380b4767d5b47fc380d64a33241e98e4b225285ebac4a
Deleted: sha256:0804fa49ae95ec657e06ebe69d016d82e67f413b2db5d480adf5d8d1b28d84d5
Deleted: sha256:430365c8e22a9207dca4638c523dc82163bca3ab8a335a71147af41d1551561f
Deleted: sha256:1ede41b1dbec1a5e4385200b62283ffb25c425275530ea9e9cc36b921186cd08
Deleted: sha256:2f6badb9fd9965261d3463591f8af4afddf5f141456de83dc994690ae64b34eb
Deleted: sha256:37803884320881cd931c77dea2ee4d8a7231dfed5a02dc595e6046ffacfa6e1b
Deleted: sha256:cefc9066dc1aa84f6cddead1bb5a8c590e8368d56fb65694e8783d70791bec20
Deleted: sha256:3bfbd2dd4507386ce56fd731b3c97d10bc058e6aa478f901466da69108db50e1
Deleted: sha256:9652363dd4c1146b3f9a519800a9f379adf0b6c4f9aece1ffe965dce5f52a8ca
Deleted: sha256:0ed190016efa0f19bcc5f1d66ffffc7b09716f3c57bcc5de74a4ce217af92278
Deleted: sha256:8399fb13d72603fdc8781075672ee25fedf8384f6721639a70dd3533250ed9e4
Deleted: sha256:ffc9b21953f4cd7956cdf532a5db04ff0a2daa7475ad796f1bad58cfbaf77a07
[aaa@qq.com ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

先写这些吧,后面的写下一篇上,要不太多了,看着不舒服~

相关标签: Linux