zoukankan      html  css  js  c++  java
  • docker-ce install on CentOS7-mini

    Docker 分为开源免费的 CE(Community Edition)和收费的 EE(Enterprise Edition)。在Docker-CE官方的源中,有stable、edge和test三个版本。本文安装的是免费的docker-ce的stable版本。

    Docker Service文件(/usr/lib/systemd/system/docker.service)对firewalld操作,确保firewalld是active(running)的。

    1 Set up the repository

    # Install required packages. yum-utils provides the yum-config-manager utility, and device-mapper-persistent-data and lvm2 are required by the devicemapper storage driver.

    1 yum install -y yum-utils device-mapper-persistent-data lvm2

    # Use the following command to set up the stable repository. You always need the stable repository, even if you want to install builds from the edge or test repositories as well.

    1 yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

    //使用yum-config-manager添加docker-ce的源。也可以使用vim或者wget将源放到/etc/yum.repos.d/文件夹。

    # Optional: Enable the edge and test repositories. These repositories are included in the docker.repo file above but are disabled by default. You can enable them alongside the stable repository.

    1 yum-config-manager --enable docker-ce-edge
    2 yum-config-manager --enable docker-ce-test

    # You can disable the edge or test repository by running the yum-config-manager command with the --disable flag. To re-enable it, use the --enable flag. The following command disables the edge and test repository.

    1 yum-config-manager --disable docker-ce-edge
    2 yum-config-manager --disable docker-ce-test

    2 Install Docker CE

    # Install the latest version of Docker CE, or go to the next step to install a specific version:

    1 yum install docker-ce

    //Docker is installed but not started. The docker group is created, but no users are added to the group.

    # To install a specific version of Docker CE, list the available versions in the repo, then select and install:

    # 1) List and sort the versions available in your repo. This example sorts results by version number, highest to lowest, and is truncated:

    1 yum list docker-ce --showduplicates | sort 

    ...

    docker-ce.aarch64 18.03.1.ce-1.el7.centos docker-ce-stable
    docker-ce.aarch64 18.03.1.ce-1.el7.centos @docker-ce-stable
    docker-ce.aarch64 18.03.0.ce-1.el7.centos docker-ce-stable

    //The list returned depends on which repositories are enabled, and is specific to your version of CentOS (indicated by the .el7 suffix in this example).

    # 2) Install a specific version by its fully qualified package name, which is the package name (docker-ce) plus the version string (2nd column) up to the first hyphen, separated by a hyphen (-), for example, docker-ce-18.03.0.ce.

    1 yum install docker-ce-<VERSION STRING>

    eg.

    1 yum install docker-ce-18.03.1.ce

    //Docker is installed but not started. The docker group is created, but no users are added to the group.

    3 Start Docker

    1 systemctl enable docker
    2 systemctl start dokcer

    //enable to start with system boot.

    4 Verify Docker

    # Verify that docker is installed correctly by running the hello-world image.

    1 systemctl status docker
    2 docker run hello-world

    ...

    Hello from Docker!
    This message shows that your installation appears to be working correctly.

    //This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.

    # Verify docker via httpd

    1 docker run -d -p 80:80 httpd

    //上一命令执行的过程如下:

    1) 从Docker Hub下载httpd镜像,其中,镜像中已经安装好了Apache HTTP Server。

    2) 启动httpd容器,并将容器的80端口映射到host的80端口,前提是host的80端口是可以访问的。

    //下面就可以通过浏览器访问host_IP验证httpd容器是否启动正常(输出It works!为正常)。

    5 Docker Accelerator

    # Docker Hub的服务器在国外,下载镜像会比较慢。DaoCloud、阿里云提供了国内的Docker镜像服务。

    # 以DaoCloud为例,配置Docker加速器

    1) 访问DaoCloud官网(https://www.daocloud.io/),点击更多->加速器,也可直接访问(https://www.daocloud.io/mirror#accelerator-doc)。

    2) 页面跳转后点击立即使用,此时需要登录,如果没有可以免费注册。

    3)  按照页面提示配置Docker加速器(每个人的link不一样)

    1 curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://xxxxxxxx.m.daocloud.io

    4) 重新启动Docker

    1 systemctl daemon-reload
    2 systemctl restart docker

    5) 验证

    1 docker info

    ...

    Registry Mirrors:
     http://xxxxxxxx.m.daocloud.io/

    6 Config to enable tcp connect

    # 默认配置下,Docker daemon 只能响应来自本地 Host 的客户端请求。如果要允许远程客户端请求,需要在配置文件中打开 TCP 监听,步骤如下:

    1) 编辑配置文件 /etc/systemd/system/multi-user.target.wants/docker.service,在环境变量 ExecStart 后面添加 -H tcp://0.0.0.0,允许来自任意 IP 的客户端连接。

    1 cat /etc/systemd/system/multi-user.target.wants/docker.service

    ...

    [Service]
    Type=notify
    # the default is not to use systemd for cgroups because the delegate issues still
    # exists and systemd currently does not support the cgroup feature set required
    # for containers run by docker
    ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0
    ExecReload=/bin/kill -s HUP $MAINPID

    2) 重启Docker daemon

    1 systemctl daemon-reload
    2 systemctl restart docker

    3) 服务器 IP 为 172.16.16.10,客户端在命令行里加上 -H 参数,即可与远程服务器通信。

    1 docker -H 172.16.16.10 info

    //info子命令用于查看Docker服务器的信息

    //配置后在本地访问docker也需要指定-H

    7 Reference

    https://docs.docker.com/install/linux/docker-ce/centos/
    https://www.daocloud.io/mirror#accelerator-doc

    http://www.cnblogs.com/CloudMan6/p/6727146.html

    http://www.cnblogs.com/CloudMan6/p/6763789.html

  • 相关阅读:
    delphi 多线程定时执行程序如何写
    delphi 把多个线程的请求阻塞到另一个线程 TElegantThread
    delphi 对TThread扩充TSimpleThread
    Delphi 线程Timer (TThreadTimer)
    vue-01-插值表达式、事件修饰符
    ORA-12516:监听程序找不到服务协议堆栈要求的可用处理程序(转)
    Io 异常: The Network Adapter could not establish the connection(转)
    "Cannot read property 'xxx' of undefined" js问题之某属性未定义
    数据库用日期作为条件来查询数据
    Docker Registry配置客户端
  • 原文地址:https://www.cnblogs.com/hxt-lingmo/p/9224400.html
Copyright © 2011-2022 走看看