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

Detailed explanation of Javascript basics

Table of contents variable Data Types Extension P...

Vue Element front-end application development table list display

1. List query interface effect Before introducing...

How to use VIM editor in Linux

As a powerful editor with rich options, Vim is lo...

How to add abort function to promise in JS

Table of contents Overview Promise Race Method Re...

How to use jsonp in vue

Table of contents 1. Introduction 2. Installation...

Introduction and tips for using the interactive visualization JS library gojs

Table of contents 1. Introduction to gojs 2. Gojs...

Brief Analysis of MySQL B-Tree Index

B-Tree Index Different storage engines may also u...

React tips teach you how to get rid of hooks dependency troubles

A very common scenario in react projects: const [...

vue+echarts realizes the flow effect of China map (detailed steps)

@vue+echarts realizes the flow effect of China ma...

8 Reasons Why You Should Use Xfce Desktop Environment for Linux

For several reasons (including curiosity), I star...