可以使用带有持续集成工具的 Docker 机器吗?

Possible to use Docker machine with continuous integration tools?

我正在尝试做的事情:使用像 CircleCI 或 GitLab 这样的持续集成工具来部署到 DigitalOcean Droplet。在本地,我可以使用 Docker 机器来 运行 类似

的东西

$ eval $(docker-machine env my-droplet)

连接到已创建的 Droplet,然后 docker run foo

是否可以通过传统的 deploy.yml 文件执行此类操作?假设我有一个 digitalocean-access-token 并且已经创建了一个 droplet。

DigitalOcean 建议的集成更多是与 Docker Cloud,这意味着您的 CI 应该将您的图像推送到 Docker Cloud,以便 DigitalOcean 在 Droplet 中使用。

参见“Deploy Horizon Using Docker Cloud & DigitalOcean" from Chris Asche

log into Docker Cloud and link your DigitalOcean account. To do this, click on 'Cloud Settings' at the bottom left. You should now see a list of Cloud Providers on the page. Click on the plug icon next to DigitalOcean to link your accounts. Note that, at the time of writing, there is a credit added to your DigitalOcean account when linked with Docker Cloud.

Once your accounts are linked, create a new DigitalOcean Node Cluster. I'm going to call mine, horizon-with-docker in the region Toronto 1.

The newly created node cluster can be used to run a stack. A stack is a collection of services and each service is a collection of containers. Stacks are created with the stack-yaml file.

Once created, revisit the node cluster created earlier to grab the IP address of your DigitalOcean droplet - my droplet IP is 159.203.61.66. Go ahead and visit your freshly deployed Horizon application at the IP address.

如果我正确理解你的问题,你可以使用这个命令来实现你想要的:

docker-machine create \ --driver generic \ --generic-ip-address=<your vm IP> \ --generic-ssh-key ~/.ssh/id_rsa \ my-droplet

然后就可以随心所欲了:

$ eval $(docker-machine env my-droplet)

这将注册机器。否则,您必须将开发环境中的所有证书和配置提供给您的 CI,这是不安全和推荐的。