Liver finishing, Docker container testing - common problems + solutions (summary)


foreword

Problem 1: When creating an nginx container and trying to mount the nginx.conf file, an error is reported: mounting “/root/nginx.conf” to rootfs at “/etc/nginx/nginx.conf” caused: mount through procfd: not a directory:

On your own server, you want to create a container through the nginx image, and mount the nginx.conf file that comes with the image

docker run -it -d -v ~/nginx.conf:/etc/nginx/nginx.conf nginx

Error:

[root@poloyy ~]# docker run -it -d -v ~/nginx.conf:/etc/nginx/nginx.conf nginx
e0e4b40446a64927603b85854c3a6472b2dfa5681fcbfa0e170c16b15e5c8fdd
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:76: mounting "/root/nginx.conf" to rootfs at "/etc/nginx/nginx.conf" caused: mount through procfd: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type.
[root@poloyy ~]# client_loop: send disconnect: Broken pipe

Extract key error messages:

mounting "/root/nginx.conf" to rootfs at "/etc/nginx/nginx.conf" caused: mount through procfd: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)?

Mounting "/root/nginx.conf" to the rootfs of "/etc/nginx/nginx.conf" resulted in: mount via procfd: not a directory: unknown: did you try to mount a directory on a file (or vice versa )

Root cause:
Direct mounting of files is not supported, only folders
can be mounted. To mount files, the host must also have a corresponding file with the same name

Solution:
You can copy nginx.conf
from the container without mounting nginx.conf first
, then you can modify nginx.conf by yourself, customize configuration items
and create an nginx container for official use

Copy nginx.conf from the test container.
Of course, you can also find nginx.conf on the Internet. The most important thing is that the host machine must have nginx.conf

docker run --name test -d nginx  
docker cp test:/etc/nginx/nginx.conf /data/

Create a formal nginx container and mount the nginx.conf file
to grant permissions

docker run --privileged -it -p 80:80 \
-v /data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro \
-v /data/nginx/conf/conf.d:/etc/nginx/conf.d:ro \
-v /data/nginx/html:/usr/share/nginx/html:rw \
-v /data/nginx/logs:/var/log/nginx -d nginx

Question 2: An error is reported after running the Mysql container: [ERROR] InnoDB: redo log file './ib_logfile0' exists

Run and start the mysql container on the local mac docker

docker run -d -p 3306:3306 --name mysql1 -v /Users/polo/data/conf:/etc/mysql/conf.d -v /Users/polo/data/mysql:/var/lib/mysql  -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7

Phenomenon:
Check the container log and find that an error is reported, and the local navicat cannot be connected

A1

The point is the first sentence, a certain file already exists, usually the environment is overwritten

Root cause:
I installed mysql through brew before, although uninstalled, but the local files have not been deleted

solution:

brew uninstall mysql
rm -rf /usr/local/var/mysql 

Uninstall mysql first, then delete the local files

Logs of normal startup of Mysql container

A2

no ERROR log

Question 3: The time obtained in the container is different from the time of the host

Execute the date command under the container and the host respectively

A3

As you can see, the time is completely different

Solution:
Method 1:
When running the container, mount the /etc/localtime directory

docker run -d -v /etc/localtime:/etc/localtime:ro --name git 

A4

The point is: -v /etc/localtime:/etc/localtime:ro

Method 2:

docker cp /etc/localtime [容器ID或名字]:/etc/localtime
The following is the most complete software test engineer learning knowledge architecture system diagram in 2023 that I compiled

1. From entry to mastery of Python programming

Please add a picture description

2. Interface automation project actual combat

Please add a picture description

3. Actual Combat of Web Automation Project

Please add a picture description

4. Actual Combat of App Automation Project

Please add a picture description

5. Resume of first-tier manufacturers

Please add a picture description

6. Test and develop DevOps system

Please add a picture description

7. Commonly used automated testing tools

Please add a picture description

Eight, JMeter performance test

Please add a picture description

9. Summary (little surprise at the end)

Only by doing our best can we create infinite possibilities; by working hard, we can welcome a brilliant future; no matter how difficult the difficulties are, perseverance will surely lead to success; as long as we have dreams in our hearts and go forward bravely, we will surely achieve extraordinary results.

Only with unremitting efforts can we create our own brilliance; only with the courage to forge ahead can we overcome all difficulties. No matter how tortuous the road ahead is, as long as you have a dream in your heart, you can sail to the other side of success. Believe in yourself, work hard, and the future will become a stage of infinite possibilities!

Every effort will turn into tomorrow's achievements. As long as you have faith and persist in struggling, you will be able to break out of the cocoon and become a butterfly, spreading your wings and flying high. Believe in your own strength, bloom the light of your dreams, and keep chasing, in order to achieve a better future.

Guess you like

Origin blog.csdn.net/shuang_waiwai/article/details/131598253