• docker镜像与仓库


    1、docker image 镜像

    容器的基石
    层叠的只读文件系统
    联合加载(union mount)
     
    2、镜像存储地址
    /var/lib/docker
    3、镜像操作
    列出镜像
    镜像标签和仓库
    查看镜像
    删除镜像
    1)列出镜像
    $docker images [OPTSIONS] [REPOSITORY]
    -a, --all=false 显示所有镜像
    -f, --filter=[] 显示时的过滤条件
    --no-trunc = false 不使用截断的模式显示数据
    -q, --quiet = false 只现实veid
    [root@text3 ~]# docker images

    REPOSITORY          TAG              IMAGE ID           CREATED           VIRTUAL SIZE

    centos         latest              eeb3a076a0be        10 hours ago         196.7 MB

    ubuntu               latest              ab035c88d533        2 weeks ago          187.9 MB

    2)镜像仓库和标签
    镜像
    REPOSITORY 仓库(包含一个一个独立的镜像)
    REGISTRY 仓库
    标签
    TAG
    ubuntu:14:04
    ubuntu:latest(如果镜像没有标签名,默认使用latest)
    3)查看镜像
    $docker inspect [OPTIONS] CONTAINER | IMAGE [CONTAINER | IMAGE…]
    -f, --format = “”
    [root@text3 ~]# docker inspect centos
     
    4)删除镜像
    $docker rmi [OPTIONS] IMAGE [IMAGE…]
    -f,  --format = false Force removal of the image
    —no-prune = false Donot delete untagged parents
    [root@text3 ~]# docker rmi $(docker images -q ubuntu) 删除所有ubuntu镜像
     
     
    获取和推送镜像
    查找镜像
    拉取镜像
    推送镜像
     
    1)查找镜像
    方法一:Docker Hub
    https://registry.hub.docker.com
    方法二:$docker search [OPTIONS] TERM
    --automated = false Only show automated builds
    --no-trunc = false Don’t truncate output
    --s, —stars = 0 Only displays with at least x stars
    最多返回25个结果
    2)拉取镜像
    方法一:$docker pull [OPTIONS] NAME [:TAG]
    -a, --all-tags=false  Download all tagged images in the repository
     
    方法二:使用 —registry-mirror 选项
    1、修改:/etc/default/docker
    2、添加:DOCKER_OPTS = “--registry-mirror=http://MIRROR_ADDR"
    https://www.daocloud.io
    3)推送镜像
    $docker push NAME [:TAG]
    docker push dormancypress/nginx
     
    构建镜像
    $docker commit 通过容器构建镜像
    $docker build 通过Dockerfile文件构建
    1)使用commit构建镜像
    $docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
    -a, —author = “” Author
    e.g.,”John Hannibal Smith hannibal@a-team.com”
    -m, —message = “” Commit message
    -p, —pause = true Pause container during commit
    例:

    [root@text3 ~]# docker commit -a 'Tale' -m 'nginx' commit_test dormancypress/commit_test1 构造镜像

    84daaea3c4fa276f777af22efaeadc65490124dc356c5219d5e7cf57554ad49a

    [root@text3 ~]# docker run -d -p 80 --name nginx_web1 dormancypress/commit_test1 nginx -g "daemon off;” 用构造的镜像生成容器

    e887d27c3cd3ea342de3b21e4c233a14bfdb80675644e15de87967651c05c4e6

    2)使用Dockerfile构建镜像
    1、创建Dockerfile
    例:
      #First dockerfile for test
      FROM ubuntu
      MAINTAINER dormancypress "k.guogao@outlook.com"
      RUN apt-get update
      RUN apt-get -y install nginx
      EXPOSE 80
    2、使用$docker build命令
    $ docker build -t="dormanctpress/df_test” .
     
     
     
     
     
     
  • 相关阅读:
    远程连接telnet和ssh的区别?(telnet如何连接)
    NFS实践(搭建页面)
    NFS挂载 卸载
    NFS实践
    03 Linux 文件管理
    02 bashshell介绍使用
    01 Linux 的渊源与发展史
    P4218 [CTSC2010]珠宝商
    P5284 [十二省联考2019]字符串问题
    广义后缀自动机(广义SAM)
  • 原文地址:https://www.cnblogs.com/TaleG/p/5352279.html
Copyright © 2020-2023  润新知