Install and Setup Docker Desktop
If Docker Desktop is not installed, refer to Docker Installation and Setup Tutorial (Windows version) for setup instructions.
1. Docker Desktop Settings
1.1 Start Docker Desktop Service
In Windows Powershell (run as Administrator), enter net start com.docker.service
to start the Docker Desktop Service.

2.2 Start docker daemon
In Windows Powershell (run as Administrator), enter cd "C:\Program Files\Docker\Docker"
to navigate to the Docker Desktop installation path. Run the command .\DockerCli.exe -SwitchDaemon
to start the Docker daemon.
2.3 Launch Docker Desktop
Right-click on Dockers Desktop to run as administrator.If an error occurs, follow the prompts. In Windows Powershell (run as Administrator), enter Enable-WindowsOptionalFeature -Online -FeatureName $("Microsoft-Hyper-V", "Containers") -All
.Enter Y
to confirm and restart the computer to apply the changes. After the restart, run Docker Desktop again as Administrator.

As shown in the image, the "Engine running" status indicates that Docker starts normally.
2.4 Launch Docker Desktop

As shown in the image, set up WSL integration with the installed Ubuntu subsystem. Click "Apply & Restart" to implement the changes.
2.5 Edit daemon.json to change the image source
To avoid the "Failed to pull image" error, modify the Docker images in daemon.json
.Please add the image repository source available for Docker that you are familiar with.

As shown in the image, add the ACR image acceleration address to the daemon.json
file. Apply the changes and restart to enable them.
2. Docker Desktop Settings
In some cases, Docker may not access the image links replaced in daemon.json
when pulling images. You can resolve issues with pulling images by setting up a Docker proxy.
2.1 Precondition
You need a static IP address or server address that can access the extranet.
2.2 Update systemd environment configuration
The pulling and management of images are handled by the Docker daemon, so it needs to be aware of the proxy server's existence. Since the Docker daemon is managed by systemd, we need to configure systemd.
1st Method: Update the http-proxy.conf of systemd
Create the directory using the following command; the configurations in this directory override the default settings of dockerd
.
sudo mkdir -p /etc/systemd/system/docker.service.d
Create a new configuration file http-proxy.conf
sudo vi /etc/systemd/system/docker.service.d/http-proxy.conf

Configure environment variables in the file. If you have created a private image repository and need dockerd
to bypass the proxy server for direct connections, set the NO_PROXY
variable:
[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80" # your IP (external or server): Port
Environment="HTTPS_PROXY=https://proxy.example.com:443" # your IP (external or server): Port
Environment="NO_PROXY=your-registry.com,127.0.0.1,*.example.com"
Multiple NO_PROXY
variable values are separated by commas and can include wildcards (*).

Reload the configuration file and restart dockerd.
sudo systemctl daemon-reload
sudo systemctl restart docker
Note: If you encounter the error "Failed to restart docker.service: Unit docker.service not found" when restarting Docker, you can use the apt
command to install Docker for repair.
Check to confirm that the environment variables are correctly configured:
sudo systemctl show --property=Environment docker

2nd Method: Update the docker.service
in systemd.
The location of the docker.service
configuration file may vary depending on the operating system. Use the following command to find the file directory:
sudo find / -name docker.service

Next, use the command to modify the docker.service
file:
sudo vi /usr/lib/systemd/system/docker.service
Add the following environment variables to the opened file:
Environment="HTTP_PROXY=http://proxy.example.com:80" #Your IP (external or server): Port
Environment="HTTPS_PROXY=https://proxy.example.com:443" #Your IP (external or server): Port
Environment="NO_PROXY=your-registry.com,127.0.0.1,*.example.com"

Press ESC
and enter :wq
to save the file content. Use the following command to load and restart:
sudo systemctl daemon-reload
sudo systemctl restart docker
2.3 Verify if the proxy is successfully set up

As shown in the image, this indicates that you can pull external images through the proxy
Last updated