Centos下的纯命令记录Docker学习(3)-基本的命令的操

2020-10-20  本文已影响0人  小钟钟同学

参考源:

菜鸟教程:https://www.runoob.com/docker/

常见DOCKER 基本命令:

DOCKER 命令:

番外补充:

常见DOCKER操作镜像 基本命令:

列举本机的所有的存在镜像 docker images

[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
tomcat              latest              891fcd9c5b3a        5 days ago          647MB
redis               4.0.14              191c4017dcdd        5 months ago        89.3MB
hell02              latest              bf756fb1ae65        9 months ago        13.3kB
ubuntu              15.10               9b9cb95443b5        4 years ago         137MB
[root@localhost ~]# docker images -a
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
tomcat              latest              891fcd9c5b3a        5 days ago          647MB
redis               4.0.14              191c4017dcdd        5 months ago        89.3MB
hell02              latest              bf756fb1ae65        9 months ago        13.3kB
ubuntu              15.10               9b9cb95443b5        4 years ago         137MB
[root@localhost ~]# docker images -q
891fcd9c5b3a
191c4017dcdd
bf756fb1ae65
9b9cb95443b5
[root@localhost ~]#

[root@localhost ~]# docker images -qa
891fcd9c5b3a
191c4017dcdd
bf756fb1ae65
9b9cb95443b5
[root@localhost ~]#


[root@localhost ~]# docker images --digests
REPOSITORY          TAG                 DIGEST                                                                    IMAGE ID            CREATED             SIZE
tomcat              latest              sha256:1c78db4bfbf4c75ab763dd463ff74731abbeadcfded2e03024b39cb0af3f1fb3   891fcd9c5b3a        5 days ago          647MB
redis               4.0.14              sha256:2e03fdd159f4a08d2165ca1c92adde438ae4e3e6b0f74322ce013a78ee81c88d   191c4017dcdd        5 months ago        89.3MB
hell02              latest              <none>                                                                    bf756fb1ae65        9 months ago        13.3kB
ubuntu              15.10               sha256:02521a2d079595241c6793b2044f02eecf294034f31d6e235ac4b2b54ffc41f3   9b9cb95443b5        4 years ago         137MB
[root@localhost ~]#
[root@localhost ~]# docker images --no-trunc
REPOSITORY          TAG                 IMAGE ID                                                                  CREATED             SIZE
tomcat              latest              sha256:891fcd9c5b3a174d9ef63832ededae9dc5c986bb1bb66fe35391a4b3a6734804   5 days ago          647MB
redis               4.0.14              sha256:191c4017dcdd3370f871a4c6e7e1d55c7d9abed2bebf3005fb3e7d12161262b8   5 months ago        89.3MB
hell02              latest              sha256:bf756fb1ae65adf866bd8c456593cd24beb6a0a061dedf42b26a993176745f6b   9 months ago        13.3kB
ubuntu              15.10               sha256:9b9cb95443b5f846cd3c8cfa3f64e63b6ba68de2618a08875a119c81a8f96698   4 years ago         137MB
[root@localhost ~]#

参数说明:

-a 表示所有的镜像(包括中间层)
-q 表示只显示镜像ID
- qa  显示ID 和 所有镜像包括中间层
--digests 显示镜像的摘要信息
--no-trunc 显示完整的镜像信息

镜像搜索 docker serach


[root@localhost ~]# docker search redis
NAME                             DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
redis                            Redis is an open source key-value store that…   8666                [OK]
bitnami/redis                    Bitnami Redis Docker Image                      165                                     [OK]
sameersbn/redis                                                                  82                                      [OK]
grokzen/redis-cluster            Redis cluster 3.0, 3.2, 4.0, 5.0, 6.0           72
rediscommander/redis-commander   Alpine image for redis-commander - Redis man…   47                                      [OK]
kubeguide/redis-master           redis-master with "Hello World!"                33
redislabs/redisearch             Redis With the RedisSearch module pre-loaded…   28
redislabs/redis                  Clustered in-memory database engine compatib…   27
oliver006/redis_exporter          Prometheus Exporter for Redis Metrics. Supp…   22
arm32v7/redis                    Redis is an open source key-value store that…   21
redislabs/rejson                 RedisJSON - Enhanced JSON data type processi…   20
bitnami/redis-sentinel           Bitnami Docker Image for Redis Sentinel         17                                      [OK]
redislabs/redisinsight           RedisInsight - The GUI for Redis                13
webhippie/redis                  Docker images for Redis                         12                                      [OK]
redislabs/redisgraph             A graph database module for Redis               12                                      [OK]
s7anley/redis-sentinel-docker    Redis Sentinel                                  10                                      [OK]
arm64v8/redis                    Redis is an open source key-value store that…   10
insready/redis-stat              Docker image for the real-time Redis monitor…   9                                       [OK]
redislabs/redismod               An automated build of redismod - latest Redi…   7                                       [OK]
centos/redis-32-centos7          Redis in-memory data structure store, used a…   5
circleci/redis                   CircleCI images for Redis                       5                                       [OK]
clearlinux/redis                 Redis key-value data structure server with t…   2
tiredofit/redis                  Redis Server w/ Zabbix monitoring and S6 Ove…   1                                       [OK]
wodby/redis                      Redis container image with orchestration        1                                       [OK]
xetamus/redis-resource           forked redis-resource                           0                                       [OK]
[root@localhost ~]#

[root@localhost ~]# docker search redis --automated
Flag --automated has been deprecated, use --filter=is-automated=true instead
NAME                             DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
bitnami/redis                    Bitnami Redis Docker Image                      165                                     [OK]
sameersbn/redis                                                                  82                                      [OK]
rediscommander/redis-commander   Alpine image for redis-commander - Redis man…   47                                      [OK]
bitnami/redis-sentinel           Bitnami Docker Image for Redis Sentinel         17                                      [OK]
webhippie/redis                  Docker images for Redis                         12                                      [OK]
redislabs/redisgraph             A graph database module for Redis               12                                      [OK]
s7anley/redis-sentinel-docker    Redis Sentinel                                  10                                      [OK]
insready/redis-stat              Docker image for the real-time Redis monitor…   9                                       [OK]
redislabs/redismod               An automated build of redismod - latest Redi…   7                                       [OK]
circleci/redis                   CircleCI images for Redis                       5                                       [OK]
tiredofit/redis                  Redis Server w/ Zabbix monitoring and S6 Ove…   1                                       [OK]
wodby/redis                      Redis container image with orchestration        1                                       [OK]
xetamus/redis-resource           forked redis-resource                           0                                       [OK]
[root@localhost ~]#

[root@localhost ~]# docker search redis --no-trunc
NAME                             DESCRIPTION                                                                            STARS               OFFICIAL            AUTOMATED
redis                            Redis is an open source key-value store that functions as a data structure server.     8666                [OK]
bitnami/redis                    Bitnami Redis Docker Image                                                             165                                     [OK]
sameersbn/redis                                                                                                         82                                      [OK]
grokzen/redis-cluster            Redis cluster 3.0, 3.2, 4.0, 5.0, 6.0                                                  72
rediscommander/redis-commander   Alpine image for redis-commander - Redis management tool.                              47                                      [OK]
kubeguide/redis-master           redis-master with "Hello World!"                                                       33
redislabs/redisearch             Redis With the RedisSearch module pre-loaded. See http://redisearch.io                 28
redislabs/redis                  Clustered in-memory database engine compatible with open source Redis by Redis Labs    27
oliver006/redis_exporter          Prometheus Exporter for Redis Metrics. Supports Redis 2.x, 3.x, 4.x and 5.x           22
arm32v7/redis                    Redis is an open source key-value store that functions as a data structure server.     21
redislabs/rejson                 RedisJSON - Enhanced JSON data type processing for Redis                               20
bitnami/redis-sentinel           Bitnami Docker Image for Redis Sentinel                                                17                                      [OK]
redislabs/redisinsight           RedisInsight - The GUI for Redis                                                       13
webhippie/redis                  Docker images for Redis                                                                12                                      [OK]
redislabs/redisgraph             A graph database module for Redis                                                      12                                      [OK]
s7anley/redis-sentinel-docker    Redis Sentinel                                                                         10                                      [OK]
arm64v8/redis                    Redis is an open source key-value store that functions as a data structure server.     10
insready/redis-stat              Docker image for the real-time Redis monitoring tool redis-stat                        9                                       [OK]
redislabs/redismod               An automated build of redismod - latest Redis with select modules.                     7                                       [OK]
centos/redis-32-centos7          Redis in-memory data structure store, used as database, cache and message broker       5
circleci/redis                   CircleCI images for Redis                                                              5                                       [OK]
clearlinux/redis                 Redis key-value data structure server with the benefits of Clear Linux OS              2
tiredofit/redis                  Redis Server w/ Zabbix monitoring and S6 Overlay based on Alpine                       1                                       [OK]
wodby/redis                      Redis container image with orchestration                                               1                                       [OK]
xetamus/redis-resource           forked redis-resource                                                                  0                                       [OK]
[root@localhost ~]#


参数说明:

--automated :只列出 automated build类型的镜像;

--no-trunc :显示完整的镜像描述;

-s :列出收藏数不小于指定值的镜像。

其他命令的补充:

其他命令补充

来源:https://juejin.im/post/6854573210697433095
作者:lannisiter
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

##列出本地images
docker images
##含中间映像层
docker images -a

##下载Redis官方最新镜像,相当于:docker pull redis:latest
docker pull redis
##下载仓库所有Redis镜像
docker pull -a redis

##单个镜像删除,相当于:docker rmi redis:latest
docker rmi redis
##强制删除(针对基于镜像有运行的容器进程)
docker rmi -f redis
##多个镜像删除,不同镜像间以空格间隔
docker rmi -f redis tomcat nginx
##删除本地全部镜像
docker rmi -f $(docker images -q)

常见DOCKER操作容器:

其他命令的来源

##新建并启动容器,参数:-i  以交互模式运行容器;-t  为容器重新分配一个伪输入终端;--name  为容器指定一个名称
docker run -i -t --name mycentos
##后台启动容器,参数:-d  已守护方式启动容器
docker run -d mycentos

##启动一个或多个已经被停止的容器
docker start redis
##重启容器
docker restart redis

##进入容器---运行的容器不会退出
docker exec -i -t  centos /bin/bash

##查看正在运行的容器
docker ps
##查看正在运行的容器的ID
docker ps -q
##查看正在运行+历史运行过的容器
docker ps -a
##显示运行容器总文件大小
docker ps -s

##停止一个运行中的容器
docker stop redis
##杀掉一个运行中的容器
docker kill redis
##删除一个已停止的容器
docker rm redis
##删除一个运行中的容器
docker rm -f redis
##删除多个容器
docker rm -f $(docker ps -a -q)
docker ps -a -q | xargs docker rm
## -l 移除容器间的网络连接,连接名为 db
docker rm -l db 
## -v 删除容器,并删除容器挂载的数据卷
docker rm -v redis

作者:lannisiter
链接:https://juejin.im/post/6854573210697433095
来源:掘金
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
~~~
上一篇 下一篇

猜你喜欢

热点阅读