【 K8S Technology Stack to build personal private cloud series of articles directory 】

  • Using K8S technology Stack to build personal private Cloud
  • Build personal private cloud using K8S Technology Stack (serial: K8S Cluster Construction)
  • Build personal Private Cloud using K8S Stack (Serial: K8S Environment Understanding and Practice)
  • Build personal Private cloud using K8S Technology Stack (Serial: Basic Image Making and Experiment)
  • Building personal Private Cloud using K8S Technology Stack (Serial: Resource Control Research)
  • Use K8S technology stack to build personal private cloud (Serial: Private Cloud Client Building)

Note: This article was published on My public account CodeSheep. You can subscribe by holding down or scanning the heart below ↓ ↓ ↓


Any cloud host vendors to provide the user’s host function is actually white is a basic operating system mirror running instances. Therefore, this blog post will explain how to build a centos image with SSH component locally and upload it to docker Hub for download.


Docker hub registration

Register at https://hub.docker.com/


Log in to the Docker Hub from the command line

On the cli, enter docker login


Create a centos7.4 image

1, the first step: go to the remote end to pull a latest centos basic image, based on this image to create

docker pull centos

Step 2: Start the Docker container

Docker run -it centos: latest /bin/bash

3. Step 3: Install SSHD in the started container

yum -y install openssh-server
yum -y install openssh-clients
Copy the code

Step 4: We will try to start the SSHD service, and we will find an error

Run the /usr/sbin/sshd command to start the SSHD service.

Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Could not load host key: /etc/ssh/ssh_host_ed25519_key
Copy the code

Let’s fix the above errors:

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 ""
Copy the code

The SSHD service should be started again without error

Step 5: Edit the sshd_config configuration file

Run vim /etc/ssh/sshd_config to change UsePAM yes to UsePAM no in the configuration file

Step 6 change the password of the root user

Run the passwd root command to enter the password twice

Step 7: We use the exit command to exit the container

Step 8: Create a centos image with SSH function based on the container you just exited

Docker commit bf5b84f8e2d8 docker. IO/hansonwang centos7.4 _ssh

(1) Note that bf5b84F8e2d8 here is the id of the container that was just run, which can be viewed by docker ps -A

IO /< your Dockerhub username >/centos7.4_ssh


Push the image to the remote end

Docker push docker. IO/hansonwang centos7.4 _ssh: the latest

Also note the push format here, which must be docker. IO /< your Dockerhub username/full image name

As shown below:

Meanwhile, if we go to docker Hub, we can also see the image we just pushed:


Effect of validation

To verify that the image is really pushed to the remote side, we delete the image that was just packaged locally and pull it from the remote side

Docker pull hansonwang/centos7.4 _ssh

Can pull down successfully:

Let’s test if the image contains SSH components: Run it and connect to the container using SSH: run the container: Docker run – d – 2222: p. 22 docker. IO/hansonwang centos7.4 _ssh: latest/usr/sbin/SSHD -d SSH access: SSH root@localhost -p 2222 will now ask you to enter your password and successfully login to the container:


Afterword.

  • The author’s more original articles are here, welcome to watch

  • My Personal Blog

The author has more SpringBt practice articles here:

  • Spring Boot application monitoring actual combat
  • The SpringBoot application is deployed in an external Tomcat container
  • ElasticSearch in SpringBt practice
  • A preliminary study on Kotlin+SpringBoot joint programming
  • Spring Boot Logging framework practices
  • SpringBoot elegant coding: Lombok plus

If you are interested, take some time to read some of the author’s articles on containerization and microservitization:

  • Use K8S technology stack to create personal private cloud serial articles
  • Nginx server configuration from a detailed configuration list
  • Docker container visual monitoring center was built
  • Use ELK to build Docker containerized application log center
  • RPC framework practice: Apache Thrift
  • RPC framework practice: Google gRPC
  • Establishment of microservice call chain tracking center
  • Docker containers communicate across hosts
  • Preliminary study on Docker Swarm cluster
  • Several guidelines for writing dockerFiles efficiently