Summary of Docker FAQs for software testing! With a solution!

1. Configure the domestic source for docker installation, and report an error HTTP Error 404 - Not Found

picture.png

[A full 200 episodes] Ultra-detailed advanced tutorials on automated testing of Python interfaces, truly simulating the actual combat of enterprise projects! !

Reason:  When configuring the domestic mirror source, the address was wrongly written, resulting in the prompt HTTP Error 404 after installing docker

Solution:

1) Go to the /etc/yum.repos.d directory

cd /etc/yum.repos.d
ll

picture.png

2) Delete all docker-related repo files, including the wrong Alibaba Cloud image just added

rm -rf docker-ce.repo
rm -rf mirrors.aliyun.com_docker-.repo

3) After deleting, re-install the docker as follows

yum -y update
yum install -y yum-utils
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli containerd.io

2. Install docker error Requires:container-selinux>=2:2.74

picture.png

Solution:  install the latest contain-selinux

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum install epel-release -y
yum install container-selinux -y

3. On the cloud server, docker pulls the mysql image very slowly, and it still fails for more than half an hour

picture.png

Reason:  The default source of docker is the official source abroad, and the download speed may be slow.

Solution:  change the docker image source to a domestic source

Alibaba cloud server solution:

1. Enter the Alibaba Cloud server console  https://account.aliyun.com/ , search for mirroring, and click Container Mirroring Service to enter

picture.png

2) Enter Mirroring Center - Mirroring Accelerator, select the operating system corresponding to the cloud server, and complete the operation according to the commands in the operation document.

picture.png

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors":["https://4zh3lxhh.mirror.aliyuncs.com"] } EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

3) After the configuration is complete, go to pull the image again, it is normal.

Tencent cloud server solution:

Same as Alibaba Cloud server solution

1) Open the /etc/docker/daemon.json configuration file

vim /etc/docker/daemon.json

2) Enter the keyboard i to enter the editor, add the following content, and press the Esc key to exit the edit, enter: wq to save and exit

{ "registry-mirrors": ["https://mirror.ccs.tencentyun.com"] }

3) Restart docker, and then perform image pull operation, it will be normal.

sudo systemctl restart docker

Commonly used images to choose from are as follows:

USTC: https://docker.mirrors.ustc.edu.cn/

Netease: https://hub-mirror.c.163.com/

Qiniu Cloud Accelerator: https://reg-mirror.qiniu.com

Alibaba Cloud: <your ID>.mirror.aliyuncs.com

Tencent Cloud: https://mirror.ccs.tencentyun.com

4. Enter the docker container and display bash-4.2#

picture.png

Reason:  The two files .bashrc and .bash_profile are missing in the root directory of the current login user of the docker container

Solution:

These two files are in the /etc/skel directory, you only need to copy these two files to /root to solve it.

bash-4.2# cp /etc/skel/.bashrc /root/
bash-4.2# cp /etc/skel/.bash_profile /root/

5. When entering the docker container, the displayed time zone is wrong

picture.png

The default time in docker is UTC time, and the server system is CST East Eight District time, separated by 8 hours.

Solution:

1) Enter the container, and write the time zone you want to set in the /etc/localtime file through the soft link command ln -s, such as Shanghai time zone

docker exec -it [container name or container ID] /bin/bash // enter the container in interactive mode
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
exit

2) Restart the container

docker restart [container name or container ID] // restart the container

picture.png

6. The mysql container on the cloud server cannot be connected using navicat

picture.png

Solution:

1. First confirm whether the corresponding mysql container has been started

2. Confirm the correctness of the connected host ip, port, user name, and password

3. After confirming all the above, if you can’t connect, please confirm whether the port of the cloud server is open

3.1 Alibaba Cloud Open Port Steps:

  • Log in to the Alibaba Cloud console--select the cloud server you purchased--more--network and security group--security group configuration

picture.png

  • Click Configuration Rules - Inbound Direction, copy an item, add the externally mapped port of the mysql container, for example 3307, click Save

picture.png

3.2 Tencent Cloud Open Port Steps:

  • Log in to the Tencent Cloud console--find the purchased server--firewall--add rules

picture.png

  • Create a new rule, add the externally mapped port of the mysql container, and click OK

picture.png

Guess you like

Origin blog.csdn.net/dad22211/article/details/132090823