2021-06-02 centos7安装docker

作者利用白嫖的阿里云服务器搭建个人网站,打算用 Docker 安装多数组件,并记录 CentOS 7 安装 Docker 的过程。包括准备工作,如确认系统版本、卸载旧版本、安装工具包;安装步骤,如配置 yum 源、选择版本安装、启动;还介绍了验证安装是否成功的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

centos7安装docker

近期在堂姐(九点澡堂子)那白嫖了一年阿里云服务器,于是准备利用起来搭建个个人网站,由于服务器配置比较低,也因为有点懒所以多数组件打算使用docker安装,也记录一下这整个过程

第一站,安装docker

准备

因为我习惯在root用户下操作,所以以下都是在root下做的,如果不喜欢自行更换,大差不差

首先要明确自己的系统版本支持docker,Docker 要求 CentOS 系统的内核版本高于 3.10,可以使用uname -r命令来查看自己的系统内核版本。我这里用的是centos7。

其次如果已经安装过docker的,想要重装或者觉得docker版本太低可以卸载重装。

yum remove docker  docker-common docker-selinux docker-engine

最后,安装工具包yum-utils

yum install -y yum-utils

安装

1.配置yum源
建议选择国内的源,速度会快一些,此处选择阿里云的

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

2.查看所有docker版本

yum list docker-ce --showduplicates | sort -r

Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
Installed Packages
docker-ce.x86_64            3:20.10.6-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:20.10.6-3.el7                    @docker-ce-stable
docker-ce.x86_64            3:20.10.5-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:20.10.4-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:20.10.3-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:20.10.2-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:20.10.1-3.el7                    docker-ce-stable
...

从中可以看到很多个版本,可从中选择任一安装

3.安装

可以从上面中任选一个版本指定安装,将以下<VERSION_STRING>替换成对应版本即可

yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io

也可以通过不指定版本直接安装最新版

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

4.启动

systemctl start docker

验证与使用

验证docker是否安装成功

1.查看docker版本

docker version

2.运行官方提供的验证镜像helloworld

docker run hello-world

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/

有以上提示信息,docker即为安装成功

使用

docker的基本使用及指令等未完待续

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值