通过 API 远程控制 docker 主机,无需 HTTPS,仅需 HTTP

通过 API 远程控制 docker 主机,无需 HTTPS,仅需 HTTP

我使用 Ubuntu 16 和 Docker 17.12.0-ce 创建了一个 VirtualBox VM,该 docker 主机名为 ,dockervm正在监听端口2373

现在在 Windows 机器上(在提示符下)我设置DOCKER_HOST=tcp://dockervm:2373并执行命令docker ps,得到:

error during connect: Get https://dockervm:2373/v1.35/containers/json: http: server gave HTTP response to HTTPS client

我如何远程控制这个docker主机没有 安全 docker 主机


现在我尝试通过 SSH 控制远程 docker 主机(教程)但是当我创建时,docker-machine我得到了这个:

PS C:\Users\Roberto> docker-machine create --driver generic --generic-ip-address=192.168.15.115 --generic-ssh-key "c:/users/roberto/.ssh/id_rsa" --generic-ssh-user=jjw ubuntu
Running pre-create checks...
Creating machine...
(ubuntu) Importing SSH key...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with debian...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Error creating machine: Error checking the host: Error checking and/or regenerating the certs: There was an error validating certificates for host "192.168.15.115:2376": tls: oversized record received with length 20527
You can attempt to regenerate them using 'docker-machine regenerate-certs [name]'.
Be advised that this will trigger a Docker daemon restart which might stop running containers.

答案1

解决了。

  • 首先,我将守护进程改为在端口 2375 上运行
  • 然后我将环境变量设置为DOCKER_HOST=<ip>:2375
  • 我终于可以交流了docker ps

相关内容