Teach you how to build a docker environment

Teach you how to set up a docker environment, every step is very detailed. Interested bloggers will learn together with the editor!

VirtualBox installation

Docker can also be installed in windows, but we usually use linux in the development process, so we choose to use linux here. Oracle provides us with VirtualBox, which is relatively simpler and easier to use than VMware.

Here I have a downloaded one, you can download it directly

Link: https://pan.baidu.com/s/1SZ4GwGBXQ4kgAb4_YlBd8Q
Extraction code: k29m

After downloading, you can install it all the way next.

Virtual machine installation and configuration

After the installation is complete, I have prepared a ready-made virtual machine for everyone here, and just import it after downloading it.

Link: https://pan.baidu.com/s/1dJr3aizEKgXI_Gu06b-O7Q
Extraction code: k6gf

Then you can import it directly. Double-click to start after importing. Some people will encounter startup failure. At this time, right-click the settings to enter the network settings and change the link mode. Here I am connected to the wifi and used a bridged network card, which can be started normally, if it can’t be started, you can try to replace it with another one.

The account is root and the password is 123456

At this time, you need to see if the virtual machine network and the computer network are in the same network segment

Check your computer ip, if the first three paragraphs are the same, it means that it is in the same network segment.
Insert picture description here

With a virtual machine, we can install a virtual machine client for ease of operation.

Install SmarTT client

Link: https://pan.baidu.com/s/1x2GtkTxF1T7zireDKb2KRw
Extraction code: r8je

Just install next all the way! Open in this place after installation


At this time, you can directly operate the virtual machine here. Although there is a client, the virtual machine must still be turned on! ! !

Next time you open the client, you can directly connect to the host we saved

Static ip configuration

Sometimes our computers always change network cables. At this time, the IP of the virtual machine will change accordingly. So here I suggest that you configure the static IP directly to avoid IP changes.

Configuration steps: https://blog.csdn.net/weixin_43888891/article/details/113622161

docker installation

1. Check the kernel version <Docker requires the kernel version of the CentOS system to be higher than 3.10>
uname -r command to check the system kernel version
Insert picture description here
If it is not necessary to execute the yum updatecommand to upgrade!

2. Update the yum package to the latest

sudo yum update

3. Install the required software packages, yum-util provides the yum-config-manager function, the other two are dependent on the devicemapper driver

sudo yum install -y yum-utils device-mapper-persistent-data lvm2

4. Set up yum source

sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo 

5. View the docker version in the warehouse

 yum list docker-ce --showduplicates | sort -r

6. Install docker

sudo yum install docker-ce

Here is whether to install or not, you can directly y.
Insert picture description here
7. Start Docker, set the boot to start, and stop Docker.
Normally, we only need to set the boot to start, and there is no need to worry about it.

sudo systemctl start docker
sudo systemctl enable docker

Command to close docker:sudo systemctl stop docker

8. View version

 docker version

Insert picture description here
9. Use it to confirm whether the startup is successful, use search to check

  docker search mysql

Insert picture description here

10. View log status success log

  systemctl status docker.service 

Insert picture description here
If the execution of the above command fails at the end, we can uninstall and reinstall

1. Query the installed package
yum list installed | grep docker has
installed an old version locally
Insert picture description here

2. Remove the installed package
yum -y remove docker.x86_64
yum -y remove docker-client.x86_64
yum -y remove docker-common.x86_64

Guess you like

Origin blog.csdn.net/weixin_43888891/article/details/113622658