|NO.Z.00006|——————————|CloudVirtualiZation|——|Cloud&Docker.V04|——|基础操作|

一、docker基础概念及命令
### --- docker三个重要概念:仓库/Repository;镜像/image;容器/Container
~~~     # 注:
~~~     仓库:仓库是用来存储镜像环境的
~~~     镜像:封装好的运行环境;镜像可以被上传到仓库里
~~~     容器:是镜像运行完成以后得到的正在运行的运行环境

docker run --name  MyWordPress  --link db:mysql -p 8080:80 -d wordpress
二、docker指令的基本用法(yuanjian):
### --- docker+命令关键字(COMMAND)+一系列的参数
### --- docker指令除了单条使用外,还支持赋值/解析变量/嵌套使用

docker info                             // 守护进程的系统资源设置      
docker search                           // docker仓库的查询
docker pull                             // docker仓库的下载
docker images                           // docker镜像查询
docker rmi                              // docker 镜像删除
docker ps                               // docker容器的查询
docker run                              // docker容器的创建启动
docker start/stop                       // docker 容器停止
三、操作示例:
### --- 注:
~~~     镜像大小占用多少存储资源:镜像的size值相加是不正确的,只能通过df来查看;
~~~     镜像是分层的,如果有使用镜像,就会跳出下载;使用公用镜像;公用显示的是源镜像大小;
~~~     size显示的是大于或者等于镜像存储单位的,万一一个公用镜像都没有。

### --- 重点overlay比dm更稳定
[root@localhost ~]# docker info
Storage Driver: overlay                                                     
[root@localhost ~]# docker search nginx
NAME                               DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
nginx                              Official build of Nginx.                        14185     [OK]         //官方镜像

[root@localhost ~]# docker pull nginx
Using default tag: latest                                                   //latest 默认的
latest: Pulling from library/nginx

[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED                  SIZE
mysql               5.7                 f07dfa83b528        Less than a second ago   448 MB
nginx               latest              ae2feff98a0c        20 hours ago             133 MB
hello-world         latest              bf756fb1ae65        11 months ago            13.3 kB
### --- 镜像名称+版本号    或者直接使用ID号;一般写四位就可以删除 

[root@localhost ~]# docker rmi hello-world:latest  
[root@localhost ~]# docker rmi bf75
Untagged: hello-world:latest
### --- docker ps只能查看当前正在运行的镜像,已经退出关闭的不显示

[root@localhost ~]# docker ps                                               
[root@localhost ~]# docker ps -a                        //可以查看所有的容器
[root@localhost ~]# docker rm 63b4                      //删除容器:docker rm+ID号前四位 或者 容器的名称   若显示正在运行的容器,加上-f强制删除
[root@localhost ~]# docker ps -a -q                     //-a:显示所有的容器, -q:只显示ID号,
63b42d67206c
8792d83ffa3e
### --- 使用for循环,先执行括号内的,再执行括号外面的。

[root@localhost ~]# docker rm -f $( docker ps -a -q )   

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

 

posted on   yanqi_vip  阅读(10)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示