🚀 開放外部連線至 Docker,有兩種方式可擇一設定

建立 ‘/etc/docker/daemon.json’

1
sudo nano /etc/docker/daemon.json

加入以下設定

1
2
3
4
{
"hosts": [ "unix:///var/run/docker.sock", "tcp://0.0.0.0:" ],
"tls": false
}

調整服務

1
sudo systemctl edit docker.service

服務指令結尾加入參數 [-H tcp://127.0.0.1:2375]

1
2
3
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://127.0.0.1:2375

重啟服務

1
2
sudo systemctl daemon-reload
sudo systemctl restart docker.service
Read more »

設定 DNS

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 刪除原始的 resolv.conf 設定
sudo rm /etc/resolv.conf

# 建立 resolv.conf 設定,加入自訂 DNS
sudo bash -c 'echo "nameserver 192.168.50.1" > /etc/resolv.conf'

# 加入 Google 的 DNS 加速
sudo bash -c 'echo "nameserver 8.8.8.8" >> /etc/resolv.conf'
sudo bash -c 'echo "nameserver 8.8.4.4" >> /etc/resolv.conf'

# 設定 /etc/wsl.conf
sudo bash -c 'echo "[network]" > /etc/wsl.conf'
sudo bash -c 'echo "generateResolvConf = false" >> /etc/wsl.conf'

# 鎖定 resolv.conf 設定
sudo chattr +i /etc/resolv.conf
Read more »
0%