[Linux] How to install a package on a server that does not have a network environment (standalone)


Not connected to the global network from the viewpoint of security such as the production environment, There are so-called standalone servers.

When you want to install additional libraries and packages on such a server How can I install it?

I've been addicted to my previous work, and I'd like to write a little summary of the solutions at that time. I hope it will be helpful to anyone.

At the end of the article, I introduce a script that automatically executes this method. (With GIF image) Since it was created by me personally, I do not guarantee the operation, but if you have a chance, please use it.


Define the words used in the article as follows:

word Definition
Standalone environment A server that does not connect to the global network. Place of installation.
Local PC My work PC. It is connected to the network.

usage environment

name OS version Remarks
Standalone environment CentOS 7 AWS EC2(For verification)
Local PC macOS Catalina
Docker container CentOS 7

Overall flow

Follow the procedure below.

  1. Launch a Docker container on your local PC
  2. Download the package in a Docker container
  3. Create the download destination folder as a repository
  4. Move the created repository to a standalone environment
  5. Set up the repository in a standalone environment
  6. Install in a standalone environment

Later in the article, I will explain the detailed procedure above.

If you don't have a Docker environment, you may be able to run it on your local PC. However, there may be cases where it does not work depending on the dependency. We recommend that you use a clean environment with almost nothing in it.

important point

--Dependency may cause the installation to fail depending on the state of the standalone environment. --For packages that have no dependencies and are single rpm, it is faster and easier to install with the rpm command. --With this method, we recommend that you install all the required packages at once.

Detailed procedure

Let's actually do it!

0. Standalone environment preparation

We have prepared AWS EC2 as a stand-alone server for use in the verification environment. In order to isolate it from the global network, communication other than ssh (port 22) is prohibited.

↓ Result of executing yum update in a standalone environment スクリーンショット 2020-02-13 18.11.11.png

1. Launch a Docker container on your local PC

Launch a Docker container in the same environment as the standalone environment as much as possible. This time, we will launch a CentOS 7 container. When you get up, let's access the container.

$ docker run -itd --name centos7 centos:centos7
$ docker exec -it centos7 bash

2. Download the package in a Docker container

First, create a directory to download the package to.

# mkdir standalone_install

Download all the packages required for the stand-alone environment in the created directory. This time, I will download git and ʻiproute2` (assortment of network commands) together.

By adding the --downloadonly option, it is possible to execute only the download without installing.

# yum install -y --downloadonly --downloaddir=standalone_install git iproute2

yum install --downloadonly --downloaddir=<directory> <package> [^1]

If you look inside the downloaded directory, you will see that it contains a large number of rpm files.

スクリーンショット 2020-02-13 19.01.37.png

3. Create the download destination folder as a repository

Install the repository creation command createrepo.

# yum install -y createrepo

Create a repository using the create repo command that you just installed. Simply specify the directory and run it to create the metadata and act as a repository.

# createrepo standalone_install

repodata is the metadata created by the create repo command. image.png

The following procedure will move the file to the standalone environment, so compress the file if necessary.

4. Move the created repository to a standalone environment

Move the repository folder created by the createrepo command to the standalone environment. This time, it's a little troublesome, but move it according to the following procedure.

  1. Exit the Docker container
  2. Copy the folder from the Docker container to your local PC
  3. Copy the folder from your local PC to the standalone environment
#exit ← Exit from the container. Ctrl+D is also OK.
$ docker cp centos7:/standalone_install/ ./
$ scp -r standalone_install standalone_ec2:/home/centos/

5. Set up the repository in a standalone environment

All that remains is to work in a standalone environment.

Create a .repo file and set up the transferred repository. The setting items are as follows.

item name Setting items
name The name of the repository
baseurl The path of the directory where the repository entity is located
gpgcheck ~~Guppigu check~~Whether to verify the GPG signature. 0=false,1=true
$ sudo vi /etc/yum.repo.d/standalone_install.repo

6. Install in a standalone environment

Specify the repository with the --enablerepo option to install the package. At that time, --disablerepo = * is set so that it does not go to search for external repositories. (The --disablerepo option must be set before the --enablerepo)

$ sudo yum install -y --disablerepo=* --enablerepo=standalone_repo git iproute2

I was able to install it this way even in the verification environment (EC2)! (This image doesn't prove it at all ... lol) スクリーンショット 2020-02-15 23.08.01.png

Summary / Bonus

The key points of this installation method are as follows.

--Use the same OS and version of Docker container as the standalone environment --Downloading the rpm file using the --downloadonly option --Creating a repository with the create repo command --Create a .repo file and set up the repository --Specify the repository with --enablerepo and install

As I mentioned at the beginning of the article, I personally created a script that automatically executes this installation method. The Readme describes how to use it, so please use it if you have the opportunity. https://github.com/hesma2/standalone_install

↓ Operation image (Steps 1 to 3 are executed by one script) demo


-Use yum, just download without installing packages -yum | Create yum repository -6.3. YUM and YUM Repository Settings

[^ 1]: Use yum to just download without installing packages

Recommended Posts

[Linux] How to install a package on a server that does not have a network environment (standalone)
How to install Linux on a 32bit UEFI PC
How to build a Python environment on amazon linux 2
How to use a tp-link wireless LAN slave unit that does not support Linux
A memo on how to easily prepare a Linux exercise environment
How to install VMware-Tools on Linux
How to install aws-session-manager-plugin on Manajro Linux
How to install a package using a repository
How to install packages on Alpine Linux
How to install Anisble on Amazon Linux 2
How to install php7.4 on Linux (Ubuntu)
How to fix a bug that jupyter notebook does not start automatically
How to install python package in local environment as a general user
Verification of how to periodically execute a script on a Linux server on Windows
Build Linux on a Windows environment. Steps to install Laradock and migrate
How to install Camunda Modeler on Manjaro Linux
How to build Java environment on Ubuntu (Linux)
How to build a Django (python) environment on docker
[AWS EC2] How to install Maven on Amazon Linux 2
How to install git on Linux such as EC2
How to run Django on IIS on a Windows server
How to build a beautiful Python environment on a new Mac and install Jupter Notebook
How to create a Python 3.6.0 environment by putting pyenv on Amazon Linux and Ubuntu
How to use GitHub on a multi-person server without a password
Install LAMP on Amazon Linux 2 and build a WordPress environment.
Parallel processing of Python joblib does not work in uWSGI environment. How to process in parallel on uWSGI?
How to build a new python virtual environment on Ubuntu
How to set up WSL2 on Windows 10 and create a study environment for Linux commands
A note on how to load a virtual environment in PyCharm
How to register a package on PyPI (as of September 2017)
How to install nkf with rpm file on Red Hat Enterprise Linux 7.7 (for non-internet environment)
How to solve the problem that APL does not start after transferring to the actual device on Kivy-iOS
I implemented a method to calculate the evaluation index (specificity, NPV) that scikit-learn does not have
A note on how to check the connection to the license server port
How to build a Python environment using Virtualenv on Ubuntu 18.04 LTS
A special Python codec that seems to know but does not know
How to continue processing after returning a response on aiohttp Server
Host the network library Mirror for Unity on a Linux server
How to install mysql-connector-python on mac
Install Arch Linux on DeskMini A300
How to create a Conda package
How to install graph-tool on macOS
How to install wkhtmltopdf (Amazon Linux2)
Run a Linux server on GCP
How to install pycrypto on Windows
How to install OpenCV on Mac
How to install MBDyn (Linux Ubuntu)
How to install PyPy on CentOS
Create a Linux environment on Windows 10
How to install TensorFlow on CentOS 7
How to install Maven on CentOS
How to install Go on Ubuntu
How to install music 21 on windows
The NVM Checksum Is Not Valid, a solution to the problem that Intel's wired LAN is not recognized on Linux
[Python] How to save the installed package and install it in a new environment at once Mac environment
A story I was addicted to trying to install LightFM on Amazon Linux
Linux screen distribution on Ubuntu Memo that wants to be a Linux screen distribution YouTuber
How to build my own Linux server
How to build a sphinx translation environment
How to install drobertadams / toggl-cli on Mac
How to add a package with PyCharm