The Docker container is started successfully but the browser cannot be accessed (after the Docker container is started, check docker ps -a and you cannot see the ports (the ports column is empty) | The linux kernel version and the docker version are not compatible)

Scenario: The Docker container starts successfully but the browser cannot access it

I am new to learning the basic operations of Docker containers. I pulled the tomcat image and entered the run container command to run a series of container operations without any problems. However, I cannot access the port when I access it through the browser.

[root@localhost ~]# docker run -d -p 8081:8080 --name mytomcat b8dfe9ade316

1. After the Docker container is started, check docker ps -a and you cannot see ports (the ports column is empty)

After testing various command lines, I finally entered the command to display all container information and found that the ports line was empty! ! !

[root@localhost ~]#  docker ps -a

Then I didn’t know what keywords to find to describe this situation, so I tried various methods, such as uninstalling and reinstalling the old version of tomcat, turning off the firewall, and setting up the firewall to allow or restrict specified IPs and ports (firewall), but none of them worked. , and even formatted the output to display the specified column, but still could not see the ports. After many twists and turns, I finally found the method of blogger Jacen_Chou and tried it, and it worked! ! ! Thank you blogger Jacen_Chou for your help. My mood was just like what the blogger said at the end. When I saw the success, I was so excited that I almost cried.

Jacen_Chou blogger’s method: “Solution to Docker port mapping not working”
https://blog.csdn.net/Jacen_Chou/article/details/84261334?utm_source=app&app_version=5.2.1&code=app_1562916241&uLinkId=usr1mkqgl919blen

The blogger said that just add it in front of -d, and I finally found out that this situation is called Docker port mapping not working.

[root@localhost ~]# docker run -itd -p 8081:8080 --name mytomcat b8dfe9ade316

Then enter docker ps -a, and finally see the contents of the ports line.

2. The linux kernel version and the docker version are incompatible

I thought the problem had been solved. Logically speaking, it was no problem. I opened the browser happily, but it still failed. I continued to look for the reason and returned to the original keyword. The docker container started successfully but could not be accessed. After searching, I saw that Qingren blogger said that the Linux system kernel may be low, and the docker version is the latest version, so it is incompatible.
I quickly checked my linux version and docker version, and the result is really like this. My docker is version 20.10.11, and linux is only 3.8. I worked on it for a long time and it turned out that it was a version incompatibility problem. I quickly entered the yum update command. Upgrade the kernel

Jacen_Chou blogger’s method: “The docker container is started successfully but cannot be accessed by the outside world” https://blog.csdn.net/qq_36971805/article/details/121460691?utm_source=app&app_version=5.2.1&code=app_1562916241&uLinkId=usr1mkqgl919blen

#Check linux kernel version
[root@localhost ~]# uname -sr

#Check docker version
[root@localhost ~]# docker version

#Upgrade the linux kernel version, upgrade all packages and also upgrade the software and system kernel
[root@localhost ~]# yum update -y

After a long wait for the upgrade, I suggest you search for how to upgrade the larger version of the Linux kernel version. Because yum update is only suitable for minor version upgrades, there are so many steps to upgrade the larger version that I am too lazy to try.
Finally, don’t forget to restart centos and the container after the upgrade.

Finally, I finally saw my damn Tom Cat~~

solution:

Check whether the Docker port mapping is successful, and whether the Linux kernel version and the Docker version are compatible. If they are not compatible, there are two methods, either lower the Docker version (uninstall the higher version and reinstall it) or upgrade the Linux kernel version. Don’t forget to restart the host after the upgrade. host.
Finished with flowers~~~

Related Posts

Regarding the solution to the problem of Windows request timeout when pinging a virtual machine

CentOS7 detailed installation tutorial–super detailed graphic introduction

ssh: connect to host localhost port 22: Connection refused

Solution to SSL failure reported during compilation and installation of python3.10

Centos7 configures Alibaba Cloud yum source

[Linux] Use of basic development tools in Linux environment – yum | vim | gcc & g++ | gdb | make & makefile | progress bar | git

Use the jenkins pipeline to complete automatic deployment of services to K8s

Huawei Cloud RDS database evaluation: performance exceeded expectations, Double 11 discounts continue

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*