03-Docker安装

Docker的基本组成

在这里插入图片描述
镜像(image) :
docker镜像就好比是一个模板,可以通过这个模板来创建容器服务, tomcat镜像==> run ==> tomcat01容器(提供服务器),通过这个镜像可以创建多个容器(最终服务运行或者项目运行就是在容器中的)。

容器( container) :
Docker利用容器技术,独立运行一个或者一 个组应用 ,通过镜像来创建的。
启动,停止,删除,基本命令!
目前就可以把这个容器理解为就是一个简易的linux系统

仓库( repository) :
仓库就是存放镜像的地方!
仓库分为公有仓库和私有仓库!
Docker Hub (默认是国外的)
阿里云…都有容器服务器(配置镜像加速!)

安装Docker

环境准备
1、Linux的基础
2、CentOS 7
3、使用Xshell 连接远程服务器进行操作
环境查看

# 系统内核是 3.10 以上的
[root@iZbp1ce780a5j2zww8kl9hZ /]# uname -r
3.10.0-1127.19.1.el7.x86_64

# 查看系统版本
[root@iZbp1ce780a5j2zww8kl9hZ /]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

安装

# 卸载旧的版本
yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

# 需要的安装包
yum install -y yum-utils

#设置镜像仓库
yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo  # 默认是国外的!

#使用阿里国内源安装docker
yum-config-manager \
    --add-repo \
    http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

#更新yum软件包索引
yum makecache fast

# 安装dokcer  docker-ce 社区   ee企业版
yum install docker-ce docker-ce-cli containerd.io

# 启动Docker
systemctl start docker

# 查看Docker版本
docker version

在这里插入图片描述

#测试docker
docker run hello-world

在这里插入图片描述

# 查看一下下载的这个hello-wor1d 镜像
[root@iZbp1ce780a5j2zww8kl9hZ /]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
hello-world   latest    d1165f221234   2 months ago   13.3kB

卸载Docker
1. Uninstall the Docker Engine, CLI, and Containerd packages:   --- 卸载依赖
$ sudo yum remove docker-ce docker-ce-cli containerd.io
2. Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes: ---- 删除资源
$ sudo rm -rf /var/lib/docker
$ sudo rm -rf /var/lib/containerd

#/var/lib/docker
docker的默认工作路径!

配置阿里云镜像加速

在这里插入图片描述
在这里插入图片描述
配置使用

sudo mkdir -p /etc/docker 

sudo tee /etc/docker/daemon.json <<-'EOF' 
{ 
    "registry-mirrors": ["https://cu5stxsx.mirror.aliyuncs.com"] 
} 
EOF 

sudo systemctl daemon-reload 

sudo systemctl restart docker

回顾HelloWorld流程
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
现在GuestOS都支持

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值