Proxy diperlukan ketika server yang menjalankan Docker tidak memiliki akses langsung ke Internet. Konfigurasikan daemon Docker untuk menggunakan server proxy untuk mengakses gambar yang disimpan di Registri Docker Hub resmi atau pendaftar pihak ketiga. Ada 2 cara untuk mengkonfigurasi proxy untuk buruh pelabuhan :
- Mengonfigurasi variabel proxy di /etc/sysconfig/docker berkas
- Mengonfigurasi variabel lingkungan
Metode 1 :Mengonfigurasi variabel proxy di file /etc/sysconfig/docker
1. Tambahkan konfigurasi berikut di /etc/sysconfig/docker berkas:
# cat /etc/sysconfig/docker export HTTP_PROXY="http://USERNAME:PASSWORD@[your.proxy.server]:[port]" export HTTPS_PROXY="https://USERNAME:PASSWORD@[your.proxy.server]:[port]"
Misalnya :
# cat /etc/sysconfig/docker HTTP_PROXY="http://user01:password@10.10.10.10:8080" HTTPS_PROXY="https://user01:password@10.10.10.10:8080"
2. Mulai ulang daemon Docker setelah menyiapkan proxy.
# service docker restart
Metode 2 :Mengkonfigurasi variabel lingkungan
1. Buat drop-in
# mkdir /etc/systemd/system/docker.service.d
2. Buat file dengan nama /etc/systemd/system/docker.service.d/http-proxy.conf yang menambahkan HTTP_PROXY variabel lingkungan:
[Service] Environment="HTTP_PROXY=http://user01:password@10.10.10.10:8080/" Environment="HTTPS_PROXY=https://user01:password@10.10.10.10:8080/" Environment="NO_PROXY= hostname.example.com,172.10.10.10"
3. muat ulang daemon systemd
# systemctl daemon-reload
4. restart buruh pelabuhan
# systemctl restart docker
5. Pastikan konfigurasi telah dimuat:
# systemctl show docker --property Environment Environment=GOTRACEBACK=crash HTTP_PROXY=http://10.10.10.10:8080/ HTTPS_PROXY=http://10.10.10.10:8080/ NO_PROXY= hostname.example.com,172.10.10.10