Solve the error during connect exception in Docker

Solve the error during connect exception in Docker

When you first start using Docker, you will inevitably get flustered when you encounter unusual problems. It’s okay, that’s how learning works, constantly finding ways to solve problems in the face of difficulties, the key is to persist, come on!

Here it comes, here comes the problem, don’t panic, look below:

We opened Docker normally and executed the command, but an error during connect exception was reported.

The following is an explanation of the corresponding exception error:

No connection could be made because the target machine actively refused it. Now we know where the problem is. Our Docker image runs on VirtualBox (Win10 Home Edition), so the target machine here is VirtualBox and there is a problem with the connection.

Two solutions:

Open VirtualBox and restart the default service.

And then it works.

You don’t have to open VirtualBox. You can also restart the default by executing the command.

Execute the command in docker:

docker-machine restart default

result:

The entry and exit execution commands can be executed smoothly. The problem has been solved. It is not difficult. I will remember it next time I encounter it.

Additional knowledge: After installing Docker on Windows, the program started in the Docker container cannot be accessed through the external ip:port method

Recently, I have been using containers to start a development project. However, I found that after starting it in a container under the Linux system using the same image, I can access it through the Linux IP:port (mapped port) and the container IP:port, but I cannot access it under Windows.

There are two solutions

Access directly on the Windows host

You can access it using LinuxIP:port

Installing Docker in Windows actually starts a Linux virtual machine and runs Docker in Linux, so it cannot be accessed directly using the window IP: port method. Here you should use the virtual machine's IP: mapped port method to access it.

Query the IP address command of the Windows Docker startup machine:

docker-machine ip default

Usually 192.168.99.100

At this time, you can successfully access it using 192.168.99.100:port

Need to access on other machines connected to Windows

When we need to access it on other machines connected to Windows, we need to use the windowsIP:port method, and then we need to configure the virtual machine.

Open VM VirtualBox, 1. Select default, right-click settings -> 2. Select "Network" in the left menu -> 3. Click "Advanced" in Network Card 1 to expand -> 4. Click Port Forwarding to open the port forwarding configuration interface

Configure in the port forwarding rule interface, click the "+" button on the right to add a port forwarding rule, fill in the name, host port, subsystem port, click OK below to save.

After saving, you can use windowsIP: host port to access it. (The host port corresponds to the Windows system port; the subsystem port is the port of the Linux virtual machine, that is, the port mapped to the container. For example, when starting a container in Docker, map the container's port 8181 to 8186, that is, -p 8186:8181, then fill in 8186 for the subsystem port here)

The above article on solving the error during connect exception in Docker is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • Example of how to install kong gateway in docker
  • Docker pull image and tag operation pull | tag
  • Docker intranet builds DNS and uses domain name access instead of ip:port operation
  • Docker container time zone adjustment operation
  • Solve the problem that docker run or docker restart will automatically exit when starting the image
  • Use nexus as a private library to proxy docker to upload and download images
  • Use docker to build kong cluster operation

<<:  Details on overriding prototype methods in JavaScript instance objects

>>:  Summary of MySQL date and time functions (MySQL 5.X)

Recommend

Mysql sql slow query monitoring script code example

1. Modify my.cnf #The overall effect is that both...

Summary of Linux date command knowledge points

Usage: date [options]... [+format] or: date [-u|-...

MySQL batch adding and storing method examples

When logging in to the stress test, many differen...

Detailed explanation of MySql data type tutorial examples

Table of contents 1. Brief Overview 2. Detailed e...

Implementation of vite+vue3.0+ts+element-plus to quickly build a project

Table of contents vite function Use Environment B...

How to implement the Vue mouse wheel scrolling switching routing effect

A root routing component (the root routing compon...

W3C Tutorial (13): W3C WSDL Activities

Web Services are concerned with application-to-ap...

Native js to realize a simple snake game

This article shares the specific code of js to im...

MySQL Quick Data Comparison Techniques

In MySQL operation and maintenance, a R&D col...

Tips for making web table frames

<br />Tips for making web table frames. ----...

JS+AJAX realizes the linkage of province, city and district drop-down lists

This article shares the specific code of JS+AJAX ...

How does MySQL achieve multi-version concurrency?

Table of contents MySQL multi-version concurrency...

Explore VMware ESXI CLI common commands

Table of contents 【Common commands】 [Summary of c...