Selasa, 07 Desember 2021

DOCKER-redhat7

 

1. Download the RHEL ISO

https://nathancatania.com/posts/installing-docker-on-red-hat-with-no-internet-access/
  • Download the RHEL ISO for your applicable version (7.2, 7.3 etc).
  • RHEL ISOs can be downloaded from the RedHat developer page (free account required).
  • You can use the below command to check your version if unsure:
cat /etc/redhat-release

2. Copy the ISO to the required servers

  • The ISO will need to be copied to all the servers which Docker is to be installed on.

Example:

scp rhel-server-7.X-x86_64-dvd.iso <user>@<hostname>:

3. Mount the ISO

  • Mount the ISO on your target server:
mount -o loop rhel-server-7.X-x86_64-dvd.iso /mnt

4. Copy the repository locally

  • Copy the repository from the mounted ISO and set the correct permissions.
cp /mnt/media.repo /etc/yum.repos.d/rhel7dvd.repo
chmod 644 /etc/yum.repos.d/rhel7dvd.repo

5. Edit the repo file

vi /etc/yum.repos.d/rhel7dvd.repo

If you haven’t used vi before, press a to enter edit mode, ESC to exit edit mode, and :wq to save and quit.

  • Change the gpgcheck=0 parameter to 1.
  • Add the following 3 lines to the end of file (but before the ~ characters in the editor):
enabled=1
baseurl=file:///mnt/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

Save and exit vi.

6. Clean the repositories

yum clean all && subscription-manager clean

7. Verify the repo works

This should generate a very long packages list if working correctly.

yum  --noplugins list

Part 2 - Install Docker CE

Attempting to install the RPM for Centos will fail due to a missing dependency. In this part, we will download Docker CE and the dependency manually and install.

=====================================

1. Download the Docker CE RPM for Centos

Note 1: At the time of this post, Docker 17.09.0 CE was the latest version available for Centos. You may wish to check for a more up-to-date version if applicable.

Note 2: The Container SELinux dependency below was for RHEL 7.3. Your version may differ. Please confirm before proceeding. On your internet-enabled machine, download the Docker 17.09.0 CE package and its dependency.

If your instance does not have internet access, you will need to complete this step on a connected machine and then transfer the files across.

Docker CE:

curl https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-17.09.0.ce-1.el7.centos.x86_64.rpm -o docker.rpm

Dependency:

curl http://mirror.centos.org/centos/7.3.1611/extras/x86_64/Packages/container-selinux-2.9-4.el7.noarch.rpm -o containerselinux.rpm

2. Install

Make sure to run the command with both RPMs in the specific order below! The dependency should be installed first!

yum install -y containerselinux.rpm docker.rpm

If the above command succeeds: congratulations! You have successfully installed Docker CE on Red Hat!

Kalau selinux error

Just install selinux latest version to fix it:


sudo yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.107-3.el7.noarch.rpm


More versions at http://mirror.centos.org/centos/7/extras/x86_64/Packages/

Older versions of 2.9: http://ftp.riken.jp/Linux/cern/centos/7/extras/x86_64/Packages/

3. [OPTIONAL] Start Docker

Start Docker and set it to start at boot.

systemctl start docker
systemctl enable docker

Part 3 - Transfer Docker images

This step is not required if you have internet access available on your server

Now that Docker is installed, there is the issue of: how do we actually get our Docker images onto the server if there is no internet access available?

The answer is: You will pull the images on another (internet-connected) machine with Docker, save the images, and then transfer them across to your server. Docker will always attempt to use a local image first before pulling the image from a remote repo.

1. Pull the required Docker images

In this example, we will be pulling the images for both Zookeeper and Kafka (your images might differ).

On an internet-enabled machine with Docker installed, run the following:

docker pull my_docker_image
save -o my_docker_image.docker my_docker_image

Replacing my_docker_image with the same of the image you want to pull and save.

For example, for both Kafka and Zookeeper:

docker pull wurstmeister/zookeeper
docker pull wurstmeister/kafka:latest
docker save -o zookeeper_image.docker wurstmeister/zookeeper
docker save -o kafka_image.docker wurstmeister/kafka

Copy the .docker file(s) you saved across to your target server.

2. Load the Docker images

On your target (non-internet connected) server, load the Docker images into inventory with:

docker load -i my_image_name

For example, again for both Kafka and Zookeeper:

docker load -i kafka_image.docker
docker load -i zookeeper_image.docker

3. Done!

You can now use Docker as you normally would with the images loaded above.

======================

Docker compose

https://docs.docker.com/compose/install/

  1. Run this command to download the current stable release of Docker Compose:

    $ sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    

    To install a different version of Compose, substitute 1.29.2 with the version of Compose you want to use.

    If you have problems installing with curl, see Alternative Install Options tab above.

  2. Apply executable permissions to the binary:

    $ sudo chmod +x /usr/local/bin/docker-compose
    

Note: If the command docker-compose fails after installation, check your path. You can also create a symbolic link to /usr/bin or any other directory in your path.

For example:

$ sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
  1. Optionally, install command completion for the bash and zsh shell.

  2. Test the installation.

    $ docker-compose --version
    docker-compose version 1.29.2, build 1110ad01
    


Tidak ada komentar:

Posting Komentar