• docker(1):docker 安装和运行简单容器


    centos 查看内核版本:

    ~]$ uname -a
    Linux ip-xx-xx-xx-xx.cn-northwest-1.compute.internal 4.14.2x8-1x2.4x2.amzn2.x86_64 #1 SMP Tue Jul 20 20:35:54 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
    
    # 命令: uname -a 
    # 内核版本为 4.14 (要用好容器技术,内核版本要在 3.8 以上 )
    # ps:结果中某些信息被本人改成了 x

    查看Centos linux 版本:

    cat /etc/redhat-release

    我用的是 Amazon 的 Linux ,命令如下:

    ~]$ cat /proc/version 
    Linux version 4.14.238-182.422.amzn2.x86_64 (mockbuild@ip-10-0-1-132) (gcc version 7.3.1 20180712 (Red Hat 7.3.1-13) (GCC)) #1 SMP Tue Jul 20 20:35:54 UTC 2021

    Amazon Linux 2 安装 Docker

    1、更新实例上已安装的程序包和程序包缓存

    sudo yum update -y

    2、安装最新的 Docker 引擎包

    sudo yum install docker

    3、 启动 Docker 服务

    sudo service docker start

    4、将 ec2-user 添加到 docker 组,以便您能够执行 Docker 命令,而无需使用 sudo

    sudo usermod -a -G docker ec2-user

    5、 退出,再重新登录以接受新的 docker 组权限。您可以关闭当前的 SSH 终端窗口并在新终端窗口中重新连接到实例,完成这一过程。您的新 SSH 会话将具有相应的 docker 组权限。

    6、 验证 ec2-user 是否能在没有 sudo 的情况下运行 Docker 命令。

    docker info

    运行 docker 的 hello world 

    ~]$ docker run hello-world
    Unable to find image 'hello-world:latest' locally
    latest: Pulling from library/hello-world
    b8dfde127a29: Pull complete 
    Digest: sha256:0fe98d7debd9049c50b597ef1f85b7c1e8cc81f59c8d623fcb2250e8bec85b38
    Status: Downloaded newer image for hello-world:latest
    
    Hello from Docker!
    This message shows that your installation appears to be working correctly.
    
    To generate this message, Docker took the following steps:
     1. The Docker client contacted the Docker daemon.
     2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
        (amd64)
     3. The Docker daemon created a new container from that image which runs the
        executable that produces the output you are currently reading.
     4. The Docker daemon streamed that output to the Docker client, which sent it
        to your terminal.
    
    # 这4步很重要;Docker 是一个典型的 CS 架构;
    # docker 客户端连接 docker 服务端,服务端发现本地没有这个镜像,就去 docker hub 把这个镜像拉到了本地,然后 docker 服务端从这个镜像中创建了一个容器,这个镜像运行了一个可执行的文件并;
    # 最后 docker 服务端把运行结果以流的方式输出到 docker 客户端,客户端把最后结果发送到了你的终端上
     

    aws Amazon Docker 文档链接:

    https://docs.aws.amazon.com/zh_cn/AmazonECS/latest/developerguide/docker-basics.html

    Code your future.
  • 相关阅读:
    JQ对JSON的增删改
    Debug编辑通过转Release找不到命名空间
    Codeforces Round #740(Div. 2)
    2021“MINIEYE杯”中国大学生算法设计超级联赛(10)
    2021“MINIEYE杯”中国大学生算法设计超级联赛(8)
    Codeforces Round #737 (Div. 2)
    2021“MINIEYE杯”中国大学生算法设计超级联赛(7)
    2021牛客暑期多校训练营8
    2021牛客暑期多校训练营7
    2021“MINIEYE杯”中国大学生算法设计超级联赛(6)
  • 原文地址:https://www.cnblogs.com/neozheng/p/15174224.html
Copyright © 2020-2023  润新知