Just like the blogs I wrote before: Offline Package Installation I
and Solve Conflicts in RPM installation
, Use rpm
or bare yum
command to install downloaded rpm file works but I find somehow this will cause some maintenance problems, for examplesql
Warning: RPMDB altered outside of yum. ** Found 51 pre-existing rpmdb problem(s), 'yum check' output follows: bash-4.2.46-31.el7.x86_64 is a duplicate with bash-4.2.46-30.el7.x86_64 binutils-2.27-34.base.el7.x86_64 is a duplicate with binutils-2.27-28.base.el7_5.1.x86_64 coreutils-8.22-23.el7.x86_64 is a duplicate with coreutils-8.22-21.el7.x86_64 cryptsetup-libs-2.0.3-3.el7.x86_64 is a duplicate with cryptsetup-libs-1.7.4-4.el7.x86_64
I need to find a way that can automatically figure out the dependency chain, install the rpm required from download pool.docker
Install createrepo
package:bash
yum install -y createrepo
Next, creates the necessary metadata for your Yum repository, as well as the sqlite database for speeding up yum operations. For example, /root/docker
directory contains all rpms that install docker needs:ide
createrepo --database /root/docker
you will find it generates a folder called repodata
that contains:ui
304457af78cd250275222993fa0da09256f64cc627c1e31fb3ec0848b28b28d8-primary.xml.gz 3d5ab2f5b706e5750e0ebe5802a278525da9cac4b9700634c51c2bfdf04a0d0e-primary.sqlite.bz2 421810a6b2d93e49bfe417404f937e17929f0d8c55953dbe8e96cbb19f40708d-filelists.sqlite.bz2 62c33f23a9485d74076d3db77064a9bdf606ce68d6702cd84fc5c6f1bcb48f01-other.sqlite.bz2 649e08cdba02219eb660f579b89e7a86cf805e4f989222cb1be556a8e0b82b5c-other.xml.gz 6cd1c3a2d6f385b1cbb878a88f86b8ef7e32d6e5c2c32c41a81f51464c3785c7-filelists.xml.gz repomd.xml
To define a new repository, you can either add a [repository]
section to the /etc/yum.conf
file, or to a .repo
file in the /etc/yum.repos.d/
directory. All files with the .repo
file extension in this directory are read by yum, and it is recommended to define your repositories here instead of in /etc/yum.conf
.this
For example, create a docker-local.repo
file in /etc/yum.repos.d/
directory, baseurl
points to the folder that holds downloaded rpms:url
[docker-local.repo] name=docker-local baseurl=file:///root/docker enabled=1 gpgcheck=0
Then if you run yum repolist all
, you will see this new added yum repository:3d
yum repolist all Loaded plugins: product-id, search-disabled-repos repo id repo name status ... docker-local.repo docker-local enabled: 134 ...
Now you can install docker by running:code
yum install -y docker-ce
yum will check local repository and launch dependencies for you.sqlite
Sometimes it's better to set enabled=0
in .repo
file to disable it by default, so you can run:
yum --enablerepo=docker-local.repo install -y docker-ce