docker entry - Image Management Command articles

First, download, upload image
 
1: Download and install centos mirror
Syntax: docker Parameter name [Mirror]
[root@host1 ~]# docker pull centos
Using default tag: latest
latest: Pulling from library/centos
a02a4930cb5d: Pull complete
Digest: sha256:184e5f35598e333bfa7de10d8fb1cebb5ee4df5bc0f970bf2b1e7c7345136426
Status: Downloaded newer image for centos:latest
 
Description: docker pull download centos mirror, very slow, you can configure docker accelerator, accelerate image download speed, they can apply themselves to Ali cloud! !
After configuring the accelerator, restart the docker services, docker again pull centos much faster
Download Accelerator :( reference http://blog.csdn.net/xlemonok/article/details/71403534)
Add the following vi /etc/docker/daemon.json//
{
"registry-mirrors": ["https://dhq9bx4f.mirror.aliyuncs.com"]
}
 
2: Upload local packaged mirror file
Syntax: docker Parameter name [Mirror]
Note: You can put your own image spread dockerhub official website go up, but only need to register a user, follow-up study it again if there is a demand
[root@host1 ~]# docker push image_name
 
 
Second, to view mirror
 
1: View of local mirror
Syntax: docker Parameters
说明:REPOSITORY:表示镜像的仓库源、TAG:镜像的标签、IMAGE ID:镜像ID、CREATED:镜像创建时间、SIZE:镜像大小!!
[root@host1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 1e1148e4cc2c 2 months ago 202MB
 
三、搜索镜像
 
1:搜素git镜像
语法:docker 【参数】 【对象】
说明:NAME:镜像仓库源的名称 、DESCRIPTION:镜像的描述、OFFICIAL:是否docker官方发布
[root@host1 ~]# docker search git
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
gitlab/gitlab-ce GitLab Community Edition docker image based … 2396 [OK]
sameersbn/gitlab Dockerized gitlab web server 1100 [OK]
gitlab/gitlab-runner GitLab CI Multi Runner used to fetch and run… 479 [OK]
gitea/gitea Gitea: Git with a cup of tea - A painless se… 163
gitlab/gitlab-ee GitLab Enterprise Edition docker image based… 134
 
四、镜像打标签
 
1:将centos镜像打成标签test1、TAG为1
语法:docker 【参数】【对象】 【镜像标签名称:镜像TAG】
说明:打标签时不加【镜像TAG】,Docker默认TAG是 latest
[root@host1 ~]# docker tag centos test1:1
[root@host1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
test1 1 1e1148e4cc2c 2 months ago 202MB
centos latest 1e1148e4cc2c 2 months ago 202MB
 
五、启动镜像容器
 
1:启动centos镜像容器
语法:docker 【参数】-itd【对象】
说明:-i表示让容器的标准输入打开,-t表示分配一个伪终端,-d表示后台启动,要把-i -t -d 放到镜像名称前面
[root@host1 ~]# docker run -itd centos
d1f6aff44e7e35215822463f55e2a28429fc50858e8b165438e594efd04675e4
 
 
六、查看运行的容器
 
1:查看启动中的容器
语法:docker 【参数】
说明:加上-a选项后可以查看所有容器,包括未运行的
[root@host1 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d1f6aff44e7e centos "/bin/bash" 3 minutes ago Up 3 minutes optimistic_aryabhat
 
七、删除镜像
 
1:删除centos镜像
语法:docker 【参数】 【镜像名称:镜像TAG:镜像ID】
说明:其中后面的参数可以是tag,如果是tag时,实际上是删除该tag。当后面的参数为镜像ID时,则会彻底删除整个镜像,所有标签也会一同删除
[root@host1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 47b19964fb50 10 days ago 88.1MB
centos latest 1e1148e4cc2c 2 months ago 202MB
test1 111222 1e1148e4cc2c 2 months ago 202MB
test2 2233 1e1148e4cc2c 2 months ago 202MB
 
[root@host1 ~]# docker rmi centos
Untagged: centos:latest
Untagged: centos@sha256:184e5f35598e333bfa7de10d8fb1cebb5ee4df5bc0f970bf2b1e7c7345136426
 
[root@host1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 47b19964fb50 10 days ago 88.1MB
test1 111222 1e1148e4cc2c 2 months ago 202MB
test2 2233 1e1148e4cc2c 2 months ago 202MB

Guess you like

Origin www.cnblogs.com/douyi/p/11573694.html