Docker安装

2023-01-18  本文已影响0人  it奔跑在路上

环境说明

我们使用的是 CentOS 7 (64-bit)

目前,CentOS 仅发行版本中的内核支持 Docker。

Docker 运行在 CentOS 7 上,要求系统为64位、系统内核版本为 3.10 以上。

查看自己的内核:

uname -r 命令用于打印当前系统相关信息(内核版本号、硬件架构、主机名称和操作系统类型等)。

[root@iZbp1j6nqm0rhlipfaevhhZ huayao]# uname -r
3.10.0-1062.12.1.el7.x86_64

查看版本信息:

cat /etc/os-release

[root@iZbp1j6nqm0rhlipfaevhhZ huayao]# 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"

安装步骤

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

2、确定你是CentOS7及以上版本,我们已经做过了

3、yum安装gcc相关环境(需要确保 虚拟机可以上外网 )

yum -y install gcc
yum -y install gcc-c++

4、卸载旧版本

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

5、安装需要的软件包

yum install -y yum-utils

6、设置镜像仓库

# 正确推荐使用国内的
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

7、更新yum软件包索引

yum makecache fast

8、安装 Docker CE

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

9、启动 Docker

systemctl start docker

10、测试命令

docker version
docker run hello-world
docker images

11、卸载

systemctl stop docker
yum -y remove docker-ce docker-ce-cli containerd.io
rm -rf /var/lib/docker

阿里云镜像加速

1、介绍:https://www.aliyun.com/product/acr

2、注册一个属于自己的阿里云账户(可复用淘宝账号)

3、进入管理控制台设置密码,开通

4、查看镜像加速器自己的

image-20230111110414857

5、配置镜像加速,==每个人的不一样,需要自己到阿里云去找配置==

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://qiyb9988.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

测试 HelloWorld

1、启动hello-world

docker run hello-world
上一篇 下一篇

猜你喜欢

热点阅读