Content outline

Oct 20, 2023
1 Min read

How to set proxy environment variables for containerd

Word systemd written in white in a bluish background of a series of data center racks.

My servers in prod are not directly exposed to the Internet.

I use a web proxy for downloading files and software into these servers. All I need to do is to set http_proxy environment variable from the shell.

But systemd services like containerd do not read the environment variables configured from the shell.

So, here’s how to set environment variables for containerd to download container images via the web proxy.

#1: Configure /etc/environment

Update the proxy environment variables in /etc/environment.


#2 Create config file for containerd service

Create directory.

sudo mkdir -p /etc/systemd/system/containerd.service.d/

Create proxy.conf file and open in vim.

sudo vim /etc/systemd/system/containerd.service.d/proxy.conf

Insert these two lines, save and close.


#3 Restart the containerd service

sudo systemctl daemon-reload
sudo systemctl restart containerd.service

Now, containerd service can download container images via the proxy server.

This method works for other systemd services like docker as well.