通过ssh将本地docker映像推送到远程服务器上,不会有麻烦。
docker-push-ssh的Python项目详细描述
Docker推ssh
将Docker映像从本地计算机推送到远程服务器,无需麻烦。
概述
docker-push-ssh
是一个命令行实用程序,用于通过ssh将Docker映像从本地计算机推送到远程计算机。
它在你的服务器上创建一个私有的Docker注册表,建立一个ssh隧道(这样注册表就不会暴露给公众)。 并通过这个ssh隧道上传你的docker镜像。
使用“Docker for Mac”在OS X上测试。
安装
通过PIP安装:
pip install docker-push-ssh
将
localhost:5000
添加到Docker客户端的不安全注册表(需要重新启动Docker):
[OS X] How to Add Insecure Registry
[Linux] How to Add Insecure Registry
将localhost:5000
添加到客户端不安全的注册表中是不方便的,但这是Docker设计的一个副作用。
使用docker-push-ssh
,每台机器只需执行一次。这允许工具通过ssh
在localhost:5000
处隧道到远程主机上的临时注册表,而不需要服务器的ssl证书。
用法:
$ docker-push-ssh --help usage: docker-push-ssh [-h][-i SSH_IDENTITY_FILE][-p SSH_PORT] ssh_host docker_image [docker_image ...] A utility to securely push a docker image from your local host to a remote host over ssh without using docker save/load or needing to setup a private registry. positional arguments: ssh_host Host to push docker image to. (ex. username@myhost.com) docker_image Docker image tag(s) to push. Specify one or more separated by spaces. optional arguments: -h, --help show this help message and exit -i SSH_IDENTITY_FILE, --ssh-identity-file SSH_IDENTITY_FILE [required] Path to the ssh identity file on your local host. Required, password auth not supported. -p SSH_PORT, --ssh-port SSH_PORT [optional] Port on ssh host to connect to. (Default is 22)
示例
首先创建一个我们可以使用的测试图像:
$ mkdir /tmp/testimage &&cd /tmp/testimage $ echo"FROM alpine" >> ./Dockerfile $ echo"RUN touch /etc/testimage" >> ./Dockerfile $ docker build -t testimage .
现在将测试图像推送到远程服务器:
$ docker-push-ssh -i ~/my_identity_file root@myserver.com testimage ...
现在testimage
将出现在您的服务器上。
注意事项
- 不支持ssh密码身份验证。只有密钥文件。