Dino Geek, try to help you

How to configure Docker to use a proxy?


You can configure Docker to use a proxy server with the following steps:

1. Create a systemd drop-in directory for the Docker service:

```
$ sudo mkdir -p /etc/systemd/system/docker.service.d
```

1. Create a new file called `/etc/systemd/system/docker.service.d/http-proxy.conf` that adds the `HTTP_PROXY` environment variable:

```
$ sudo nano /etc/systemd/system/docker.service.d/http-proxy.conf
```

In the text file that opens, add the following:

```
[Service]
Environment=“HTTP_PROXY=http://proxy.example.com:80/“
```

Replace `http://proxy.example.com:80/` with the URL of your proxy server. If your proxy server requires a username and password, include them in the URL:

```
Environment=“HTTP_PROXY=http://username:password@proxy.example.com:80/“
```

1. If you have an HTTPS proxy server, create a version of the above configuration in a file named `/etc/systemd/system/docker.service.d/https-proxy.conf`:

```
$ sudo nano /etc/systemd/system/docker.service.d/https-proxy.conf
```

In this text file that opens, add the following:

```
[Service]
Environment=“HTTPS_PROXY=https://proxy.example.com:443/“
```

Replace `https://proxy.example.com:443/` with the URL of your HTTPS proxy server.

1. After creating the configuration files, flush changes and restart Docker with these commands:

```
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
```

1. Check that Docker is now using the proxy server with the following command:

```
$ systemctl show —property Environment docker
Environment=HTTP_PROXY=http://proxy.example.com:80/ HTTPS_PROXY=https://proxy.example.com:443/
```

If everything is configured correctly, the command should return the URLs of your proxy servers.

Keep in mind that these instructions will configure Docker to use these proxy servers for every new container. If you want to use proxy servers for specific containers, you should pass the `HTTP_PROXY` and `HTTPS_PROXY` environment variables to those containers using the `-e` option of the `docker run` command.


Simply generate articles to optimize your SEO
Simply generate articles to optimize your SEO





DinoGeek offers simple articles on complex technologies

Would you like to be quoted in this article? It's very simple, contact us at dino@eiki.fr

CSS | NodeJS | DNS | DMARC | MAPI | NNTP | htaccess | PHP | HTTPS | Drupal | WEB3 | LLM | Wordpress | TLD | Domain name | IMAP | TCP | NFT | MariaDB | FTP | Zigbee | NMAP | SNMP | SEO | E-Mail | LXC | HTTP | MangoDB | SFTP | RAG | SSH | HTML | ChatGPT API | OSPF | JavaScript | Docker | OpenVZ | ChatGPT | VPS | ZIMBRA | SPF | UDP | Joomla | IPV6 | BGP | Django | Reactjs | DKIM | VMWare | RSYNC | Python | TFTP | Webdav | FAAS | Apache | IPV4 | LDAP | POP3 | SMTP

| Whispers of love (API) | Déclaration d'Amour |






Legal Notice / General Conditions of Use