文章目录

  • 1.遇到问题:yum源无法找到要安装的包文件
  • 2.更换yum源信息
  • 3.yum其他相关命令
  • 4.移除旧版docker
  • 5.安装yum工具 & docker






本文涉及内容:

  • 全新的服务器,想安装docker遇到的问题
  • 配置yum源
  • 安装依赖包等




1.遇到问题:yum源无法找到要安装的包文件

拿到一台新的服务器,想直接通过yum安装docker的,发现出现了点问题

[root@10-23-134-84 yum.repos.d]# yum install docker
Loaded plugins: fastestmirror, langpacks, versionlock
Loading mirror speeds from cached hostfile
Excluding 1 update due to versionlock (use "yum versionlock status" to show it)
No package docker available.
Error: Nothing to do


[root@10-23-134-84 yum.repos.d]# yum versionlock status
Loaded plugins: fastestmirror, langpacks, versionlock
Loading mirror speeds from cached hostfile
0:cloud-init-19.4-7.el7.centos.3.*					# 注意这句话,使用的是centos3的安装镜像源
versionlock status done
[root@10-23-134-84 yum.repos.d]#


[root@10-23-134-84 yum.repos.d]#
[root@10-23-134-84 yum.repos.d]# yum versionlock clear
Loaded plugins: fastestmirror, langpacks, versionlock
versionlock cleared
[root@10-23-134-84 yum.repos.d]#
  • yum versionlock 是为了锁定某些软件的版本,防止软件升级对系统造成的影响。
  • yum versionlock clear,我们可以解除锁定
  • 再次安装docker,发现没有可用的安装源
  • 通过yum -C search XXX 再次确认本地缓存的yum源信息
[root@10-23-134-84 yum.repos.d]# yum install docker
Loaded plugins: fastestmirror, langpacks, versionlock
Loading mirror speeds from cached hostfile
No package docker available.
Error: Nothing to do



[root@10-23-134-84 yum.repos.d]# yum -C search docker
Loaded plugins: fastestmirror, langpacks, versionlock
================================================================== N/S matched: docker ==================================================================
docker-compose.noarch : Multi-container orchestration for Docker
golang-github-fsouza-go-dockerclient-devel.x86_64 : Client for the Docker remote API
imagefactory-plugins-Docker.noarch : Cloud plugin for Docker
pcp-pmda-docker.x86_64 : Performance Co-Pilot (PCP) metrics from the Docker daemon
python-docker-scripts.noarch : Collection of scripts to help manage Docker
python-dockerfile-parse.noarch : Python library for Dockerfile manipulation
python2-avocado-plugins-runner-docker.noarch : Avocado Runner for Execution on Docker Containers
python2-docker-squash.noarch : Docker layer squashing tool
python2-dockerpty.noarch : Python library to use the pseudo-tty of a docker container
python36-docker.noarch : A Python library for the Docker Engine API
python36-docker-pycreds.noarch : Python bindings for the docker credentials store API
python36-dockerpty.noarch : Python library to use the pseudo-tty of a docker container
kdocker.x86_64 : Dock any application in the system tray
kompose.x86_64 : Tool to move from 'docker-compose' to Kubernetes
reg.x86_64 : Docker registry v2 command line client

  Name and summary matches only, use "search all" for everything.




2.更换yum源信息

添加docker的yum源也可以,或者直接替换掉服务器的yum源,这样就后续安装其他工具就不用麻烦了!

# 方法一:添加软件源信息

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 方法二:修改yum源

1) 安装wget & 安装epel第三方源
yum install -y wget
yum install epel-release

2) 备份/etc/yum.repos.d/CentOS-Base.repo文件
cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.back

3) 下载阿里云的Centos-6.repo文件
# CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
# CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
# CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo


4) 重新加载yum
yum clean all
yum makecache fast
  • yum clean all
    清理缓存
  • yum makecache
    把服务器的包信息下载到本地电脑缓存起来,makecache建立一个缓存
    以后用install时就在缓存中搜索,提高了速度。
    配合yum -C search xxx使用,不用联网检索就能查找软件信息

再次搜索docker包文件,发现结果多了很多,且有了我们需要的docker-client

[root@10-23-134-84 yum.repos.d]# yum  -C search docker
Loaded plugins: fastestmirror, langpacks, versionlock
================================================================== N/S matched: docker ==================================================================
cockpit-docker.x86_64 : Cockpit user interface for Docker containers
docker-client.x86_64 : Client side files for Docker						# 这个是我们需要的
docker-client-latest.x86_64 : Client side files for Docker				# 最新版本的也有
docker-common.x86_64 : Common files for docker and docker-latest
docker-compose.noarch : Multi-container orchestration for Docker
docker-distribution.x86_64 : Docker toolset to pack, ship, store, and deliver content
docker-latest-logrotate.x86_64 : cron job to run logrotate on Docker containers
docker-latest-v1.10-migrator.x86_64 : Calculates SHA256 checksums for docker layer content
docker-logrotate.x86_64 : cron job to run logrotate on Docker containers
docker-lvm-plugin.x86_64 : Docker volume driver for lvm volumes
docker-registry.x86_64 : Registry server for Docker
docker-v1.10-migrator.x86_64 : Calculates SHA256 checksums for docker layer content
golang-github-fsouza-go-dockerclient-devel.x86_64 : Client for the Docker remote API
imagefactory-plugins-Docker.noarch : Cloud plugin for Docker
pcp-pmda-docker.x86_64 : Performance Co-Pilot (PCP) metrics from the Docker daemon
podman-docker.noarch : Emulate Docker CLI using podman
python-docker-py.noarch : An API client for docker written in Python
python-docker-pycreds.noarch : Python bindings for the docker credentials store API
python-docker-scripts.noarch : Collection of scripts to help manage Docker
python-dockerfile-parse.noarch : Python library for Dockerfile manipulation
python2-avocado-plugins-runner-docker.noarch : Avocado Runner for Execution on Docker Containers
python2-docker-squash.noarch : Docker layer squashing tool
python2-dockerpty.noarch : Python library to use the pseudo-tty of a docker container
python36-docker.noarch : A Python library for the Docker Engine API
python36-docker-pycreds.noarch : Python bindings for the docker credentials store API
python36-dockerpty.noarch : Python library to use the pseudo-tty of a docker container
docker.x86_64 : Automates deployment of containerized applications
docker-latest.x86_64 : Automates deployment of containerized applications
docker-novolume-plugin.x86_64 : Block container starts with local volumes defined
kdocker.x86_64 : Dock any application in the system tray
kompose.x86_64 : Tool to move from 'docker-compose' to Kubernetes
oci-systemd-hook.x86_64 : OCI systemd hook for docker
oci-umount.x86_64 : OCI umount hook for docker
reg.x86_64 : Docker registry v2 command line client





3.yum其他相关命令

1、yum -y update 升级所有包,改变bai软du件设zhi置和系统dao设置,系统版本内核都zhuan升级。

2、yum -y upgrade升级所有包,不改变软件设置和系统设置,系统版本升级,内核不改变。
linux yum命令详解:

1、yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及SUSE中的Shell前端软件包管理器,基於RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软体包,无须繁琐地一次次下载、安装,yum提供了查找、安装、删除某一个、一组甚至全部软件包的命令,而且命令简洁而又好记。

2、yum的命令形式一般是如下:yum [options] [command] [package ...]其中的[options]是可选的,[command]为所要进行的操作,[package ...]是操作的对象。
yum info yum

yum search redis 或者 yum list |grep redis
# docker rpm包文件
https://download.docker.com/linux/centos/





4.移除旧版docker

如果新的服务器上docker版本比较旧,可以先移除旧的版本

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





5.安装yum工具 & docker

# 安装依赖的工具
sudo yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2


# 使用如下命令就应该可以安装docker了
yum install docker-ce  					# 安装最新版本
yum install docker-ce-<VERSION STRING>  # 安装指定版本

docker file 更换yum源 docker容器配置yum源_docker

docker file 更换yum源 docker容器配置yum源_centos_02

docker file 更换yum源 docker容器配置yum源_docker file 更换yum源_03





《yum源配置的三种方法》