In this article, we will describe the process of creating a Docker image and corresponding containers for local mirror repositories of various Linux-based Operating Systems, flavors, and versions.
By creating OS package repositories in Docker containers, the deployment architecture would need only the Docker host server on which repository Docker containers for various OS flavors can be deployed.
Please contact JetPatch support for access.
What are the benefits of creating Repositories in Docker Containers?
- Reduces hardware resource requirements
- Reduces operational overhead
The solution would require the following components:
- Supported Operating Systems for the Host machine (the Docker container): RHEL8, OL8, CentOS7 The Host machine must have a high-speed internet connection (Fast Ethernet 100 Mbps and above)
- The Host machine must be able to communicate with relevant repos (no firewall issues)
- Adequate disk space for the configured repositories. (see sizing guide)
- The docker package is installed on Host machine for managing the docker images and containers.
- Each OS flavor and version has an independent docker image and container for providing the local repository.
- The repository container has the OS repository and also exposes the repository through HTTP/HTTPS using Nginx web server.
- There is an additional docker image and container which provides the reverse
proxy functionality using Nginx. The Proxy container listens on HTTP/HTTPS for web
requests and forwards the requests to appropriate OS repository containers based on
the request URI endpoint.
Supported Operating Systems
- CentOS 6
- CentOS 7
- RHEL 7
- RHEL 8
- Ubuntu 18.04
- Ubuntu 20.04
- Ubuntu 22.04
- Oracle Linux 7
- Oracle Linux 8
- Script Path: /repos_install.sh
- Reads configuration from /etc/repos_install.conf
- Removes the previous containers and images for each of the configured OS flavors and versions.
- Pull the Docker image for each of the configured OS flavor and version, and Nginx Proxy from the configured JetPatch Docker Hub repository.
- Create Docker volumes for each of the configured OS flavors and versions, if not available. (Note: Old Docker volumes are not deleted)
- Creates a Docker Network named ‘repos_network’. All the containers are part of this network.
The Management Script
- Script path - /bin/jetpatch_repos.sh
- Reads config from /etc/repos.conf
- Start/Stop/Restart the repository containers
Each of the repository containers has the following features:
- The repositories are created at /var/www/html/.
- Docker volume is named as _repos_vol mounted at /var/www/html
- Nginx web server with Root Directory at /var/www/html/
- Repository created at start of container.
- Repository updated every 24 hours.
- The repository containers retain the cache in the corresponding Docker volumes. Restart of a container will use the previously downloaded repository cache.
Nginx Proxy Container
Nginx Proxy container runs Nginx web server. The web server implements a reverse proxy and https termination for the repository containers. The OS repositories can be accessed using Host IP and OS name as endpoint. The reverse proxy supports both HTTP and HTTPS requests.
Ex: To access RHEL 7 repository, URL to use would be http:///rhel7/ or https:///rhel7/
Installation & Management Steps:
1. Login to the Centos 7 Host server as 'root' user, create a work folder, and cd to the
# mkdir work_repos
# cd work_repos
2. Copy the given tarball (jetpatch_repos.tar.gz) in this new folder. Attached at the bottom of this article. You can also use the following 'wget' command
# wget --no-check-certificate https://files.intigua.com/f/15edd11d49/?raw=1
3. "Untar" the tarball using the following command
# tar -xf jetpatch_repos.tar
4. Edit the installation config file ‘repos_install.conf’ and configure the OS flavors and version for which Docker image/containers of local repositories have to be installed
Ex: Enabling local Centos 7 and RHEL 8
5. Edit the Docker Hub account and repository details from which the Docker images have to be pulled. Currently, images are at the following location
6. Execute the installation script repos_install.sh
Note: The docker-ce installation may fail on RHEL 8.7 Please install it manually (dnf install --allowerasing docker-ce) and then rerun repos_install.sh
7. Verify the Docker images have been installed
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
itjetpatch/repos rhel8_repos_img eeb77a198132 6 days ago
itjetpatch/repos centos7_repos_img d145b88e9904 6 days ago
8. Copy the sample local repository configuration file from extras/repos.conf to
# cp extras/repos.conf /etc/repos.conf
9. Edit the /etc/repos.conf file to enable the required repository containers and
- Edit your RedHat 7 and 8 Subscription details (user, password)
Note: Redhat "Simple Content Access" is not currently supported. Disable it before installation the first run (jetpatch_repos.sh start). After the docker registration it can be enabled again.
# For RHEL8 repo, RedHat Customer Portal subscription credentials
# For RHEL7 repo, RedHat Customer Portal subscription credentials
- Edit your OL 7 and 8 (Subscription and CSI details).
10. Start the Docker containers using the following command
# jetpatch_repos.sh start
11. Verify that all the configured containers are started
# docker ps
Endpoint URL of Repositories to be Configured on Client Machines
- The following steps should be performed on all client servers that are configured to sync with the local repositories (as per the relevant OS). We highly recommend using our run-task capabilities, to easily distribute the configurations
- The "HOST-IP" parameter value can be either the IP of the host or the hostname.
For every OS type: (i.e RHEL7, CentO6, Ubuntu 14.04)
1. Disable all current repositories in the Local Repository server by running disable-all-repos.sh attachment on the client-server.
2. Create a .repo file that will be added to the /etc/yum.repos.d directory on every server using the repositories. That file should look similar to the following file.
3. Insert the relevant configuration from the below list and save file.
Oracle Linux 7
Oracle Linux 8
Troubleshooting and Advanced Configuration
- Verify there are no firewall issues between host and repo config.
- Check docker logs by running the following command (example with OL7 container)
docker logs -n 100 -f oraclelinux7_repos_con
Note: you can also use docker logs --help
Modify Cron Job Schedule
docker exec -it oraclelinux7_repos_con /bin/bash
Additional Useful Commands
- To stop the containers, use the following command
# jetpatch_repos.sh stop
- To cleanup everything including docker containers, images, volumes, and network, use
the command from the work_repos dir.
#sh repos_install.sh cleanupall
- To cleanup the docker container, image, and volume for specific OS repo, run the
#sh repos_install.sh clean <os>
#sh repos_install.sh clean rhel7
The same can also be done in the following way.
Edit the config file ‘repos_install.conf’ and set the OS_REPOS variable to the list of
OS’s to be cleaned up
Ex: OS_REPOS=”centos7 rhel8”
Then run the following command from the 'work_repos' folder:
#sh repos_install.sh clean
#sh repos_install.sh clean
name=Oracle Linux $releasever BaseOS Latest ($basearch)
name=Oracle Linux $releasever AppStream Latest ($basearch)
name=Oracle Linux $releasever Addons Latest ($basearch)
name=Oracle Linux $releasever UEKR6 Latest ($basearch)
Please sign in to leave a comment.