Setting up a Proxy Server on the Docker Platform

Step-by-step tutorial on how to configure a proxy server in Docker using the command line interface (CLI) and the config.json configuration file.

Олександр Л.
Preview

Олександр Л.

12 June 2025

2637

2637

12 June 2025

Proxy server configuration may be required on the Docker platform in a number of cases. The most common ones are bypassing web provider limits and testing software you developed across multiple geolocations. Let's start by looking at the concept of Docker.

What Docker is

Docker is a set of platform-as-a-service (PaaS) products that use OS-level virtualization to deliver software in packages called containers, that is, to perform containerization of packages. The service has different tiers based on payment: free and premium with advanced features. This software was released in 2013. In other words, Docker is a platform for developing, delivering, and running software, where you can separate your software from your infrastructure. Thus, the assembled container can be run on different operating systems. In addition, you will be pleased to know that the Docker platform supports SSL, which provides an excellent level of information and network security when working with it, in particular, when testing application performance. Containerized information contains:

  • The software itself, the launch of which is required by the developer;
  • The runtime environment — a virtual machine with a set of minimally necessary processes;
  • Files required to run the software;
  • Server.

StableProxy

Whether you need anonymous proxies, premium business solutions, or just want to buy cheap proxies — we have it all.


Configuring a Proxy in Docker

There are 2 ways to configure it: via the command line and using a config file. Working in the command line looks like this:

  1. Since you will be using the proxy.example.com:Port parameter, you need to find out the IP address of your proxy and the port used.
  2. In the command line, write the docker build command, which creates the config. It is necessary to use the --build-arg argument in it. The full command will look like this: Bash
    docker build --build-arg HTTP_PROXY="http://proxy.example.com:Port" .
    
  3. Then, in the same command line, enter the docker run command to launch the created config. It is necessary to use the --env argument. The full command will look as follows: Bash
    docker run --env HTTP_PROXY="http://proxy.example.com:Port" redis
    

Configuring a Docker proxy using a config file looks like this:

  1. In the working directory, find the .docker folder. It should contain a file named config.json. Create it if it is missing.
  2. In the file, using your favorite code editor, enter the lines: JSON
    {
     "proxies": {
       "default": {
         "httpProxy": "http://proxy.example.com:Port",
         "httpsProxy": "https://proxy.example.com:Port",
         "ftpProxy": "https://proxy.example.com:Port",
         "noProxy": "*.test.example.com,.example.org,127.0.0.0/8"
       }
     }
    }
    
  3. In place of proxy.example.com:Port, your IP and port data should be specified, just like in the command line example.
  4. In the config file, as seen from the code above, you can use 4 proxy options:
    • HttpProxy — for the http option with no encryption;
    • HttpsProxy — for the https option with existing encryption;
    • ftpProxy — for the ftp option to transfer files using ftp;
    • noProxy — for routing direct traffic.

You must use similar proxy options when working with the command line, depending on what your proxy is. After saving the docker proxy config file, the information you specified will apply to all new containers and to ready-made containers downloaded from the Docker repository.


Frequently Asked Questions

How do I set up authentication (username and password) for a proxy in Docker?

If your proxies require a username and password, you must include them directly in the proxy URL inside the configuration file or command. The format is: http://username:[email protected]:Port. Note that if the password contains special characters (like @, :, /), they must be URL-encoded.