zoukankan      html  css  js  c++  java
  • docker安装和hub

    yum install wget
    wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
    yum list docker-ce --showduplicates|sort -r
    yum install docker-ce docker-ce-cli containerd.io
    systemctl start docker
    systemctl status docker -l
    docker run hello-world
    systemctl enable docker
    
    =======================
    
    docker info
    
    =======================
    这就是完整的过程
    编辑dockerfile文件》登录公共registry》build》本地运行》推送》其它机器拉取
    
    
    cat > Dockerfile <<EOF
    FROM busybox
    CMD echo "Hello world! This is my first Docker image."
    EOF
    
    docker login
    如果没有打a1这个标签,默认就是latest
    docker build -t createyuan/my-first:a1 .
    最后要加上一个dockerfile文件的路径,在当前目录下,也要指定./,不然报错
    
    加速一下(配置国内镜像站点),不然会报TLS handshake timeout错误
    echo "DOCKER_OPTS="--registry-mirror=https://registry.docker-cn.com"" >> /etc/default/docker
    
    systemctl status docker -l
    systemctl restart docker
    systemctl status docker -l
    
    docker build -t createyuan/my-first:a1 .
    docker run createyuan/my-first:a1
    
    有时推送不成功,多试几次,试了三次
    第一次net/http: TLS handshake timeout
    第二次read tcp 192.168.7.201:41794->104.18.124.25:443: read: connection reset by peer
    第三次a1: digest: sha256:5738039995376e9eac8be145ffde81fe5781f6385406cd2c2deb7352e940369e size: 527
    
    docker push createyuan/my-first:a1
    
    The push refers to repository [docker.io/createyuan/my-first]
    d1156b98822d: Mounted from library/busybox
    a1: digest: sha256:5738039995376e9eac8be145ffde81fe5781f6385406cd2c2deb7352e940369e size: 527
    
    =========================
    删除本地的镜像
    docker image ls
    docker rmi -f e3303b21e364
    或者
    docker rmi -f createyuan/my-first:a1
    
    Untagged: createyuan/my-first:a1
    Untagged: createyuan/my-first@sha256:5738039995376e9eac8be145ffde81fe5781f6385406cd2c2deb7352e940369e
    Deleted: sha256:e3303b21e364adb0df734ac558f07cfcaeab1e4d6a5db87d4b03fcd90a2d37bb
    
    运行,结果就是重新拉取镜像
    docker run createyuan/my-first:a1
    Unable to find image 'createyuan/my-first:a1' locally
    a1: Pulling from createyuan/my-first
    53071b97a884: Already exists
    Digest: sha256:5738039995376e9eac8be145ffde81fe5781f6385406cd2c2deb7352e940369e
    Status: Downloaded newer image for createyuan/my-first:a1
    Hello world! This is my first Docker image.
    =============================
    构建第二个版本
    docker build -t createyuan/my-first:a2 .
    推送第二个版本
    docker push createyuan/my-first:a2
    运行
    docker run createyuan/my-first:a2

     

  • 相关阅读:
    C#添加修改删除文件文件夹大全
    实用且不花哨的js代码大全
    vs2005 2008快捷键
    C#:String.Format数字格式化输出
    获取农历日期
    Vim 常用快捷键
    一个简单的makefile示例及其注释
    nginx源码剖析(1)概要
    利用Vim 打造开发环境(一)>Linux 字符界面 vim的配置
    Ubuntu 9.10设置摘要
  • 原文地址:https://www.cnblogs.com/createyuan/p/10888519.html
Copyright © 2011-2022 走看看