1、下載、上傳鏡像
1:下載安裝centos鏡像
語法:docker 【參數】【鏡像名稱】
[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
說明:docker pull 下載centos鏡像,速度很慢,能夠經過配置docker加速器,加速下載鏡像速度,能夠自行到阿里雲申請!!
配置完加速器,重啓docker服務,再次docker pull centos會快不少
加速器下載地址:(參考 http://blog.csdn.net/xlemonok/article/details/71403534)
vi /etc/docker/daemon.json//加入以下內容
{
"registry-mirrors": ["https://dhq9bx4f.mirror.aliyuncs.com"]
}
2: 上傳本地打包鏡像文件
語法:docker 【參數】【鏡像名稱】
說明:能夠把本身的鏡像傳到dockerhub官方網站上去,但前提是須要先註冊一個用戶,後續若是有需求再研究吧
[root@host1 ~]# docker push image_name
2、查看鏡像
1:查看本地的鏡像
語法:docker 【參數】
說明:REPOSITORY:表示鏡像的倉庫源、TAG:鏡像的標籤、IMAGE ID:鏡像ID、CREATED:鏡像建立時間、SIZE:鏡像大小!!
[root@host1 ~]#
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 1e1148e4cc2c 2 months ago 202MB
3、搜索鏡像
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
4、鏡像打標籤
1:將centos鏡像打成標籤test一、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
5、啓動鏡像容器
1:啓動centos鏡像容器
語法:docker 【參數】-itd【對象】
說明:-i表示讓容器的標準輸入打開,-t表示分配一個僞終端,-d表示後臺啓動,要把-i -t -d 放到鏡像名稱前面
[root@host1 ~]#
docker run -itd centos
d1f6aff44e7e35215822463f55e2a28429fc50858e8b165438e594efd04675e4
6、查看運行的容器
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
7、刪除鏡像
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