docker client使用远程docker engine

概览:

说明

  • 本机运行docker client # 就是docker CLI
  • 远程服务器运行docker server # 就是docker engine

安装

  • client

下载最新版本:https://download.docker.com/mac/static/stable/x86_64/
镜像:https://download.docker.com/mac/static/stable/x86_64/

client我是安装在osx主机上,就是将下载的复制到你的环境目录里。

  • server

server直接安装就可以,跟普通的安装无异。

通讯

为了docker服务器端与客户端的通讯,官方建议使用ssh通讯。所以设置ssh免密,你也可以采用其他通信方式。

免密设置完成,就可以添加以下环境变量,将里面的用户名和主机地址改成自己的。

1
export DOCKER_HOST='ssh://ubuntu@172.16.107.5'

Q & A

“docker” is damaged…

Q
在MacOS安装docker CLI后运行,出现此错误。

1
"docker" is damaged and can’t be opened. You should move it to the Trash.

A

1
xattr -cr <app path>

Reference