Docker

安装

  1. OS requirements
    To install Docker Engine, you need a maintained version of CentOS 7 or 8. Archived versions aren’t supported or tested.

    The centos-extras repository must be enabled. This repository is enabled by default, but if you have disabled it, you need to re-enable it.

    The overlay2 storage driver is recommended.

  2. 使用存储库安装

    首次安装Docker Engine之前,需要设置Docker存储库。之后,您可以从存储库安装和更新Docker。

    设置存储库
    安装yum-utils软件包(提供yum-config-manager 实用程序)并设置稳定的存储库。

    sudo yum install -y yum-utils

    #官方镜像
    #sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

    #阿里云镜像
    sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  3. 安装Docker引擎

    sudo yum install docker-ce docker-ce-cli containerd.io
  4. 启动Docker

    #启动
    sudo systemctl start docker

    #停止
    sudo systemctl stop docker

    #测试
    sudo docker run hello-world

基本概念

Docker镜像

Docker容器

Docker Registry

镜像与容器的区别:

容器是由镜像实例化而来,这和我们学习的面向对象的概念十分相似,我们可以把镜像看作类,把容器看作类实例化后的对象。

也可以说镜像是文件, 容器是进程。 容器是基于镜像创建的, 即容器中的进程依赖于镜像中的文件, 这里的文件包括进程运行所需要的可执行文件, 依赖软件, 库文件, 配置文件等等

Author: Jiayi Yang
Link: https://jiayiy.github.io/2021/07/06/Docker/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.