Back to Blog

إعداد البروكسي داخل حاويات Docker

أحد أكبر التحديات في بيئات التطوير المؤسسية (Enterprise) هو تشغيل Docker خلف Corporate Proxy. إذا لم تقم بالإعداد الصحيح، ستفشل أوامر docker pull ولن تتمكن الحاويات من تحديث الحزم.

إعداد البروكسي لخدمة Docker (Daemon)

لكي يتمكن Docker نفسه من سحب الصور (Images)، يجب إنشاء ملف إعداد للخدمة.
مسار الملف (Linux): /etc/systemd/system/docker.service.d/http-proxy.conf


[Service]
Environment="HTTP_PROXY=http://proxy.example.com:8080"
Environment="HTTPS_PROXY=http://proxy.example.com:8080"
Environment="NO_PROXY=localhost,127.0.0.1,docker-registry.local"
                    

بعد ذلك، أعد تحميل الخدمة: systemctl daemon-reload && systemctl restart docker.

إعداد البروكسي داخل الحاويات (Containers)

لكي تستطيع التطبيقات داخل الحاوية الوصول للإنترنت (مثلاً apt-get update)، يمكنك تمرير المتغيرات أثناء التشغيل أو إعدادها في ~/.docker/config.json لتكون افتراضية.

الطريقة اليدوية (Docker Run)


docker run -e HTTP_PROXY=http://proxy.example.com:8080            -e HTTPS_PROXY=http://proxy.example.com:8080            ubuntu apt-get update
                    

الطريقة الدائمة (User Config)

قم بتعديل ~/.docker/config.json:


{
 "proxies": {
   "default": {
     "httpProxy": "http://proxy.example.com:8080",
     "httpsProxy": "http://proxy.example.com:8080",
     "noProxy": "localhost,127.0.0.1"
   }
 }
}
                    

Disclosure: we may earn a commission if you purchase through some links.

Services Related To This Article

These offers are related to privacy, password security, and development workflows. Replace the current links with your real affiliate links through environment variables.

Default Links Need Replacement

Proton

Privacy, mail, and VPN

A strong fit for privacy-focused visitors who want VPN and secure email under one brand.

Explore Proton

Surfshark

Consumer VPN

Best on pages about geo-blocking, privacy, and public Wi-Fi protection.

Try Surfshark

NordVPN

High-converting VPN

A clear offer for users who need a paid, more durable alternative to a free proxy.

View NordVPN

1Password

Password management

The best match for password, secrets, team access, and personal security pages.

Discover 1Password

DigitalOcean

Developer cloud hosting

A strong fit for proxy setup, server, and infrastructure content aimed at developers and small teams.

Start with DigitalOcean