其他分享
首页 > 其他分享> > 2.docker镜像的基础命令

2.docker镜像的基础命令

作者:互联网

1.docker的主要内容

(1).docker是一个cs架构
(2).docker主要:镜像 容器 仓库 网络 存储 监控
(3).docker是一个软件的打包技术

2.docker镜像基础命令

1.docker search Nginx(搜索镜像)
[root@docker03 ~]# docker search nginx
NAME                              DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
nginx                             Official build of Nginx.                        12314               [OK]                
jwilder/nginx-proxy               Automated Nginx reverse proxy for docker con…   1698                                    [OK]
richarvey/nginx-php-fpm           Container running Nginx + PHP-FPM capable of…   746                                     [OK]
linuxserver/nginx                 An Nginx container, brought to you by LinuxS…   83                                      
2.docker pull nginx (官网仓库下载镜像,不加latest,默认下载最新版)
[root@docker03 ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
000eee12ec04: Pull complete
3.docker push (上传镜像)
[root@docker03 ~]# docker push nginx
4.docker images (查看本地已有镜像)
[root@docker03 ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              231d40e811cd        2 weeks ago         126MB
5.docker rmi (删除镜像)
[root@docker03 ~]# docker rmi nginx:latest 
Untagged: nginx:latest
Untagged: nginx@sha256:50cf965a6e08ec5784009d0fccb380fc479826b6e0e65684d9879170a9df8566
Deleted: sha256:231d40e811cd970168fb0c4770f2161aa30b9ba6fe8e68527504df69643aa145
6.docker tag(给镜像打标签)
[root@docker03 ~]# docker tag nginx:latest nginx:v1
7.docker load -i docker_kod.tar.gz (本地镜像导入)
[root@docker03 ~/docker]# ls
docker_kod.tar.gz
[root@docker03 ~/docker]# 
[root@docker03 ~/docker]# docker load -i docker_kod.tar.gz 
b5e11aae8a8e: Loading layer [==================================================>]  202.9MB/202.9MB
8.docker import (导入镜像,images没有镜像名和标签)
[root@docker03 ~/docker]# docker import docker_kod.tar.gz 
[root@docker03 ~/docker]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
<none>              <none>              c1863e2b0717        35 seconds ago      627MB
9.docker save(保存镜像到当前目录)
[root@docker03 ~/docker]# docker save nginx:latest  -o docker_nginx.tar.gz
10.docker inspect nginx:v1 (查看镜像属性)
[root@docker03 ~/docker]# docker inspect nginx:v1 
11.docker image prune(清理无人使用的镜像和拉取到一半的镜像,删除镜像缓存)
[root@docker03 ~/docker]# docker image prune 
WARNING! This will remove all dangling images.
Are you sure you want to continue? [y/N] y
Deleted Images:
deleted: sha256:c1863e2b07171e582113544e6c19660cd3fee7d6f1d89401529f8472732c8e33
deleted: sha256:56d69e4a0819cab19e224724de86de73c8dfcd8ee5f01e08288b20cfb49c4d52
12.docker更改拾取(重启容器生效)
[root@22732407347e /]# /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 
13.删除<none>镜像
[root@docker03 ~]# docker image prune 

标签:命令,nginx,docker03,镜像,docker,root,latest
来源: https://www.cnblogs.com/zhangfushuai/p/16370511.html