Docker 学习(一)Docker 概述及安装

1、Docker 介绍

Docker 官网:https://www.docker.com/

Docker 文档地址:https://docs.docker.com/

Docker 仓库地址:https://hub.docker.com/

Docker 是一个开源的应用`容器引擎`,让开发者可以打包自己的应用和依赖到一个可移植的`镜像`中,然后发布到任何 Linux 或者 Windows 机器上
Docker 也可以实现虚拟化。容器完全使用沙箱机制,相互之间不会有任何的接口

2、Docker 基本组成

Docker Image 镜像

Docker 镜像(Image)就是一个只读的模板,镜像可以用来创建 Docker 容器,一个镜像可以创建很多容器。比如类是镜像,对象就是容器

Docker Container 容器

ocker 利用容器(container)独立运行的一个或者一组命令,容器是使用镜像创建的运行实例
容器可以被启动、开始、停止、删除,每个容器都是相互隔离的,保证安全的平台
容器的定义和镜像几乎一模一样,也是一堆层的统一视角,区别在于容器最上面那一层是可读可写的

仓库(repository)

仓库(repository)是集中存放镜像文件的场所,用來保存各种打包好的软件镜像
仓库(Repository)和仓库注册服务器(Registry)是有区别的,仓库注册服务器上往往存放着多个仓库,每个仓库包含了多个镜像,每个镜像有不同的标签(tag)
仓库分为 public 公开仓库和 private 私有仓库两种形式

3、安装 Docker

官网安装参考手册:https://docs.docker.com/engine/install/centos/

3.1 检查当前系统版本,高于 3.10 支持 Docker

uname-r

在这里插入图片描述

3.2 安装前先进行卸载

yum remove docker \
           docker-client \
           docker-client-latest \
           docker-common \
           docker-latest \
           docker-latest-logrotate \
           docker-logrotate \

在这里插入图片描述

3.3 安装依赖

  sudo yum install -y yum-utils device-mapper-persistent-data \
  lvm2

3.4 设置仓库

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

阿里云国内镜像

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

在这里插入图片描述

3.5 安装 Docker

yum -y install docker-ce docker-ce-cli containerd.io

3.6 查看 Docker 版本

docker version

在这里插入图片描述

3.7 启动 Docker

# 启动docker
systemctl start docker
# 加入开机启动
systemctl enable docker

在这里插入图片描述

3.8 验证是否安装成功

docker run hello-world

安装成功显示下面代码!

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete 
Digest: sha256:95ddb6c31407e84e91a986b004aee40975cb0bda14b5949f6faac5d2deadb4b9
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.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

4、配置

Docker 官方镜像仓库 https://hub.docker.com/

# 在 docker/daemon.json 文件中
{
	"registry-mirrors":["https://registry.docker-cn.com"], # 镜像地址
	"insecure-registries":["ip:port"] # IP 和 端口
}

sudo systemctl daemon-reload
sudo systemctl restart docker
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一起来搬砖呀

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值