So I have a single machine on which I have installed CentOS Minimal and nothing more. It is completely isolated. This means the following:
- It can never be connected to another server or laptop
- The ONLY thing I can connect to it is a USB-disk.
My goal:
- Run
yum install docker
on it so it can run containers.
So I googled around on how to download a batch of RPMs and their dependencies, and then install them on an offline system.
So I did this on my macOS laptop:
$ docker run -v $PWD/pkg:/pkg centos:7
# mkdir /tmp/empty
# yum install -y \
--installroot /tmp/empty \
--releasever 7 \
--downloadonly \
--downloaddir /pkg \
docker
Now I have lots of RPM files inside a folder. I put that folder on a USB stick and stick it into my isolated CentOS machine. Then I run:
$ yum install /tmp/pkg/*
...
Error: Package: rpm-python-4.11.3-32.el7.x86_64 (installed)
Requires: rpm = 4.11.3-32.el7
Removing: rpm-4.11.3-32.el7.x86_64 (installed)
rpm = 4.11.3-32.el7
Updated By: rpm-4.11.3-35.el7.x86_64 (/rpm-4.11.3-35.el7.x86_64)
rpm = 4.11.3-35.el7
I have also tried to make the folder into a repository by running createrepo
inside it on my Mac via docker (since I do not have createrepo
on the isolated machine and cannot install anything on it). But it gives me the exact same error.
So what are my options here? It looks to me that because of dependency hell I have to actually mirror the whole CentOS repository. If I wanted a package from EPEL I would have to mirror that one as well. That's lots of gigabytes to transfer and store just to install docker on an isolated machine.
Is there any viable solution to this?
Bonus question: What if I run RHEL on the isolated machine instead of CentOS?
Your best bet would be to maintain a more complete mirror on that USB disk. You can use
reposync
to get a remote repository mirrored to your storage. Run it regularly to keep it current. Then, usecreaterepo
to create/update your repo metadata. Finally, on the isolated host, configure a yum repo for the mountpoint of that USB disk.Any thing else is going to be a nightmare when depsolving.
I think you can run
rpm -q -R -p <package.rpm>
(there may be a yum equivalent) to view the required dependencies of a package. You could pipe that output to a call to download those dependencies. Obviously you'd need to do that on a network enabled machine but you could move the resulting files to the disconnected machine and install them iteratively. Ordering them could be a problem I suppose but you'd have all the required items and if you just ran the install multiple times, you'd eventually get everything.You mentioned docker and CentOS, so not sure if you've seen this question already: Installing Docker on an isolated (no internet) Centos 7 box?