docker
Docker
Set Up Docker's apt Repository#
Official#
Alibaba Cloud Public Mirror#
Alibaba Cloud ECS VPC Mirror#
Install Docker Packages#
Configure a Pull Proxy for Docker Engine#
If docker pull needs to go through a proxy, configure the Docker Engine daemon (dockerd) first. On Linux systems that use systemd, there are generally two common approaches. The host-level commands below assume you are already running in a root shell.
Option 1: daemon.json#
Docker Engine 23.0+ supports proxy configuration directly in /etc/docker/daemon.json:
Restart Docker after saving the file:
Option 2: systemd Service Environment Variables#
If you prefer service-level configuration, add proxy environment variables to docker.service:
Verify that the variables were loaded:
Rootless Docker#
If you use rootless Docker, the systemd path moves to the current user's directory and the commands should be run as that user:
Notes:
- Proxy settings in
daemon.jsontake precedence over environment variable configuration. NO_PROXYshould usually include internal domains, private registries,localhost, and127.0.0.1.- If the proxy URL contains special characters such as
#?!()[]{}, escape them as described in the Docker docs when usingsystemdenvironment variables. - These settings apply to Docker Engine. Docker Desktop does not use the
daemon.jsonproxy configuration described here.
Configure Proxy for Containers and Builds#
Configuring dockerd only covers requests made by the daemon itself, such as docker pull and docker push. If processes inside containers need proxy access, or if docker build needs proxy access to download dependencies, configure client-side proxy settings as well.
Set Proxy for a Single Container#
Set Proxy for a Single Build#
Notes:
- For builds, prefer
--build-arginstead of baking proxy settings intoENVinstructions in the Dockerfile. - Proxy URLs may contain sensitive information. Avoid committing authenticated proxy addresses to the repository.