Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use K8S technology stack to make basic mirror image and experiment

Shulou Source: shulou.com Published: 2022-06-01 06:56:45 09月14日 Update

This article is about how to use the K8S technology stack for basic mirror production and experiments. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it with the editor.

To put it bluntly, the host function provided by any CVM manufacturer to users is a running instance of the basic image of the operating system. Therefore, this blog post will explain how to build a local centos base package image with ssh components and upload it to docker hub for download.

Docker hub registration

Registration address: https://hub.docker.com/

Log in to docker hub from the command line

Enter: docker login on the command line

Make a centos7.4 image

# * 1. Step 1: * * pull the latest basic centos image from the remote end and create it based on this image.

Docker pull centos

# * * 2. Step 2: * * start the docker container

Docker run-it centos:latest / bin/bash

# * * 3. Step 3: * * install sshd in the launched container

Yum-y install openssh-serveryum-y install openssh-clients

# * 4. Step 4: * * Let's try to start the sshd service and we will find an error

Start the sshd service command: / usr/sbin/sshd-D reports the following error:

Could not load host key: / etc/ssh/ssh_host_rsa_keyCould not load host key: / etc/ssh/ssh_host_ecdsa_keyCould not load host key: / etc/ssh/ssh_host_ed25519_key

Let's solve the above mistakes:

Ssh-keygen-t rsa-f / etc/ssh/ssh_host_rsa_key-N "" ssh-keygen-t ecdsa-f / etc/ssh/ssh_host_ecdsa_key-N "" ssh-keygen-t ed25519-f / etc/ssh/ssh_host_ed25519_key-N ""

Starting the sshd service again at this point should be error-free.

# * * 5. Step 5: * * Edit sshd_config configuration file

Execute the command: vim / etc/ssh/sshd_config changes the original UsePAM yes in the configuration file to UsePAM no

# * * 6. Step 6: * * change the password of root

Execute the command: passwd root can enter the password twice

# * * 7. Step 7: * * We use the exit command to exit the container

# * * 8. Step 8: * * based on the container you just exited, let's create a centos image docker commit bf5b84f8e2d8 docker.io/hansonwang/centos7.4_ssh with ssh function.

(1) Note that the bf5b84f8e2d8 here is the id of the container you just ran, which can be viewed with docker ps-a. (2) Note the commit format here, which must be docker.io//centos7.4_ssh.

Push mirroring to the remote end

Docker push docker.io/hansonwang/centos7.4_ssh:latest

Also note that the push format here must be docker.io/

Tags: Mirror container command production run foundation password error service input technology experiment success host function that is file more format user Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS MySQL Microsoft Apple Shulou Technology