Share via

ADO Proxy Configuration in Dockerfile for Azure Pipelines

Hungry Panda 45 Reputation points
2025-07-16T14:08:47.6+00:00

I want to create a Docker image that includes some SDK, tools and compilers, and then upload it to Docker Hub. This image should be ready for use in Azure Pipelines by others. The challenge I'm facing is with the proxy configuration. Rest other installation is done and validated.

How can I set up the ADO proxy (formerly VSTS proxy) in the Dockerfile? Currently, I've used our company's proxy configuration to build the image. Additionally, do I need to set up an ADO account to test this?

Some of the suggestions I see on internet is to pass the proxy as arg while building the docker image but that can't be done here as I'm supposed to upload a ready-made image to the dockerhub.

P.S. I'm very new to ADO, so bear with me if I mess up any terms or concepts!

Azure DevOps

5 answers

Sort by: Most helpful
  1. Durga Reshma Malthi 11,595 Reputation points Microsoft External Staff Moderator
    2025-07-16T14:54:24.56+00:00

    Hi Hungry Panda

    In your Dockerfile, you can hardcode proxy environment variables at image runtime, like this:

    # Base image
    FROM ubuntu:22.04
    # Set environment variables globally (system-wide)
    ENV HTTP_PROXY="http://proxy.company.com:8080"
    ENV HTTPS_PROXY="http://proxy.company.com:8080"
    ENV NO_PROXY="localhost,127.0.0.1,.company.com"
    # Optional: configure APT & wget/curl with proxy
    RUN echo 'Acquire::http::Proxy "http://proxy.company.com:8080";' >> /etc/apt/apt.conf.d/01proxy
    # Your SDK/tools installation
    RUN apt-get update && apt-get install -y \
        build-essential \
        wget \
        curl \
        && rm -rf /var/lib/apt/lists/*
    # Optional: for tools like git, npm, etc.
    RUN git config --global http.proxy http://proxy.company.com:8080 \
     && npm config set proxy http://proxy.company.com:8080
    # Set working directory
    WORKDIR /workspace
    

    Here you can use ENV Instructions in Dockerfile, this ensures that any tools inside the container like curl, npm, nuget, etc. respect the proxy settings.

    Yes, to test the agent registration and pipeline execution, you’ll need:

    • An Azure DevOps organization (you can create one for free)
    • A Personal Access Token (PAT) with agent pool permissions
    • A self-hosted agent pool created in ADO

    You can set up a sample pipeline that uses your Docker image like this:

    pool:
      vmImage: 'ubuntu-latest'
    jobs:
    - job: testDocker
      container: yourdockerhubusername/your-image-name:latest
      steps:
      - script: |
          echo "Testing tools and proxy..."
          echo $HTTP_PROXY
          curl -I https://www.google.com
        displayName: 'Test inside container'
    

    Hope this helps!

    Please Let me know if you have any queries.

    Was this answer helpful?

    2 people found this answer helpful.
    0 comments No comments

  2. Durga Reshma Malthi 11,595 Reputation points Microsoft External Staff Moderator
    2025-07-16T16:18:55.9966667+00:00

    Hi Hungry Panda

    If your Docker image has hardcoded proxy settings like:

    ENV HTTP_PROXY=http://proxy.mycompany.com:8080 
    ENV HTTPS_PROXY=http://proxy.mycompany.com:8080
    

    then any tool inside the container (like curl, npm, nuget, etc.) will attempt to route traffic through that proxy even if the user running the container is outside your company’s network.

    If you're using Azure DevOps Services (https://dev.azure.com), you do not need to configure an ADO proxy.

    Try this, instead of hardcoding, you can parameterize the proxy settings so users can inject their own values at runtime:

    Instead of baking the proxy, make it overridable. Here’s how:

    # Do NOT hardcode company proxy directly
    ENV HTTP_PROXY=""
    ENV HTTPS_PROXY=""
    ENV NO_PROXY="localhost,127.0.0.1"
    

    Then in Azure Pipelines (inside your org), define the proxy variables:

    jobs:
    - job: test
      container: yourdockerhubuser/your-image:latest
      variables:
        HTTP_PROXY: http://proxy.mycompany.com:8080
        HTTPS_PROXY: http://proxy.mycompany.com:8080
        NO_PROXY: localhost,127.0.0.1,.mycompany.com
      steps:
      - script: curl https://google.com
    

    Outside users can run the image without setting proxy, and it will just work. They can still set the proxy manually like this if needed:

    docker run -e HTTP_PROXY=http://proxy.acme.com:8080 myimage:latest
    

    Hope this helps!

    Please Let me know if you have any queries.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

  3. Durga Reshma Malthi 11,595 Reputation points Microsoft External Staff Moderator
    2025-07-22T16:09:57.5266667+00:00

    Hi Hungry Panda

    You can use Microsoft Hosted Agents but, in this case, if urgent, you can set up self-hosted agent.

    When did you submit the free parallelism, usually you need to wait for some days as Microsoft cannot guarantee immediate access.

    Go to your Azure DevOps -> Organization settings -> Parallel jobs -> Check if Hosted Windows/Linux macOS shows 0 jobs and if request a free tier is still available.

    Alternatively, you can run pipelines using a self-hosted agent

    • Set up a private build agent on your local machine or VM
    • Modify your pipeline like:
        pool:
        name: Default 
      

    Additional References:

    https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/windows-agent?view=azure-devops&tabs=IP-V4

    Hope this helps!

    Please Let me know if you have any queries.

    Was this answer helpful?

    0 comments No comments

  4. Hungry Panda 45 Reputation points
    2025-07-16T16:56:31.4033333+00:00

    Thank you so much Durga Reshma Malthi for this detailed explanation. I'll try out your suggestions and get back if needed.

    Was this answer helpful?


  5. Hungry Panda 45 Reputation points
    2025-07-16T15:47:59.21+00:00

    Hi Durga Reshma Malthi,

    Thanks for the quick response. This is the way I've hardcoded my company's proxy in the Dockerfile. But the requirement is to configure ADO proxy, I don't have any idea on this.
    If someone outside my company's network uses this docker image having my company's proxy hardcoded, will they be able to use tools like curl?

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.