码迷,mamicode.com
首页 > 其他好文 > 详细

3.docker容器的常用命令

时间:2020-01-06 18:09:53      阅读:83      评论:0      收藏:0      [点我收藏+]

标签:sha   usr   alt   efault   rom   none   当前目录   one   eve   

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 

3.docker容器的常用命令

标签:sha   usr   alt   efault   rom   none   当前目录   one   eve   

原文地址:https://blog.51cto.com/13723701/2464626

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!