• docker入门-镜像管理命令篇


    一、下载、上传镜像
     
    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
     
     
    二、查看镜像
     
    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
     
    三、搜索镜像
     
    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
  • 相关阅读:
    第六次学习笔记
    第四篇笔记
    第三篇学习笔记
    第二篇学习笔记
    第一篇学习笔记
    px与dp、sp之间的转换
    SQLite的使用(二):数据增删改查
    Logcat的级别以及Logcat的调试使用
    Android 创建服务(一)
    简说SQLite
  • 原文地址:https://www.cnblogs.com/douyi/p/11573694.html
Copyright © 2020-2023  润新知