2020年2月22日 星期六

啟用 Docker Remote API 遠端呼叫

Docker Remote API 是以 Unix Socket 作連接
想要透過遠端請求的話,就必須設定監聽的 port

step 1


創建 /etc/systemd/system/docker-tcp.socket 檔案,內容如下:

[Unit]
Description=Docker Socket for the API  
[Socket]
ListenStream=8888  
Service=docker.service  
[Install]
WantedBy=sockets.target 


step 2


執行以下指令,(重新)啟動服務:

systemctl stop docker

systemctl enable docker-tcp.socket
systemctl enable docker.socket

systemctl start docker-tcp.socket
systemctl start docker


step 3


測試與驗證:

curl -X GET http://localhost:8888/info




參考資料:


在運行systemd的Linux上啟用對Docker API的遠程訪問

Docker开启Remote API 访问 2375端口




沒有留言:

張貼留言