Build Docker & k8s environment from scratch and use + understand

Actually I'm real 2022-09-23 10:18:13 阅读数:133

builddockerk8senvironmentscratch

Although it is cold rice for the Internet, it is the first time for me to do it. After all, I can't find the answer you want on the Internet.╮(╯▽╰)╭

First step

Install Linux CentOS 7, I clicked this post, very detailed.

It's just that I pressed 8 in the post and I pressed 7.

After pressing the operating system for a day, the virtual machine has been unable to connect to the Internet. I searched a lot of answers on the Internet, but I didn't solve it. It fulfilled my first sentence in the article, and finally found that I disabled the network of the virtual machine.It's done, it's done, and it's easy to use after it's enabled.

Here I installed 1 virtual machine, and then copied 2, a total of 3 virtual machines, ready to be a K8S cluster in the future.But after installation, I didn't set anything, it's the system default configuration

Second step

Install a Docker,

Installation is to start directly after installing static decompression.It is still recommended to use rpm installation.

The RPMs are installed as follows:

Official website rpm download address

https://download.docker.com/linux/centos/7/x86_64/stable/Packages/

Upload the downloaded rpm to the server, I created one myself under home, docker_install

Run the installation command after entering: yum install -y *.rpm

I didn't encounter any missing dependencies in my installation, run it after installation

Static installation is as follows:

Official website static installation download address download: https://download.docker.com/linux/static/stable/x86_64/

I downloaded the latest version of docker-19.03.8.tgz at this point in time. I found that there is also a docker-rootless-extras-19.03.8.tgz corresponding to him. I have not downloaded this package, for the time beingDon't know what to do.

After downloading, I copied it to the /home directory of virtual machine 1,

After decompression command: tar -xvf docker-19.03.8.tgz

Then copy docker to the command set: cp docker/* /usr/bin/

Then start docker. After this command, you can see the startup log. It should be easy to see if the startup is successful: dockerd &

Successful startup screenshot

Whether it is rpm or compressed package installation, the test is as follows after success: There is still a pit here, which is the second command I typed, and I will talk about this pit below.

After that, type a few basic docker commands to see if it is successful:

Check the version, the return result of this command does not mean that the docker startup was successful, I was able to check the version before but it kept failing: docker -v

View the image list. If this command is successful, it should mean that docker has been started successfully. Below are screenshots of the two commands: docker image ls

I could get things done in one day, but after 3 or 4 days, I couldn't access anything on the company network, so I spent most of the time debugging the network, but it still didn't work.

Let's talk about the pit of a virtual machine first. I use VM12 and use NAT mode. After this mode is completed, except for one problem, I can telnet through Baidu's 80 to disconnect, but I use VM12 on my local machine.The virtual machine I pressed will not work, and I cannot telnet through Baidu, so in the end I don't know if my virtual machine can't connect to the Internet, or it just can't telnet.The form of expression is that I can't connect to the official Docker image repository, nor can I connect to the domestic 163 image repository, although my local browser can open these two repositories.I worked on this for a long time, and finally found that someone said that there is a problem with telnet in NAT mode. After that, I will not worry about this problem.But I run the Linux command: yum update works fine and can download the update package. My colleague said that this is the performance of being able to connect to the Internet.But I can't connect to the Docker warehouse all the time, which leads to my DockerFile can't run, because the first sentence in the DockerFile file must be FROM, it is not easy to use the Docker image if you can't connect to the Internet, your docker serviceThere is also no way to download the download mirror from the official website.

After the environment is clicked, I am ready to publish my own image. I got it by referring to the following post. I tried eclipse, because I can't access Google, or it may be because of the company's network. Anyway, I failed to install the Docker plug-in in eclipse..So I got it with IDEA, and this post was published with IDEA.

https://blog.csdn.net/wugenqiang/article/details/86560752p>

After posting according to the post, docker can run my image program, and then I encountered a small pit, because according to the theory my image should be successfully published to the Alibaba Cloud server, but I typed the above command docker image ls, nothing, I don't know what this command is for, and if anyone knows, I hope you can answer it for me, thank you.

After that, I used the command docker images and found the image I uploaded, which means the release was successful.

Let's talk about my understanding here. If I only have a few servers, I don't think docker is needed, but if I have tens to tens of thousands of servers, it is not realistic to manually release the version. At this time, I need to useWhen it comes to docker and K8S, we will continue to study K8S in the future.

copyright:author[Actually I'm real],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/266/202209231010447078.html