Transfer is a docker CLI plugin that enables pushing images directly to a remote docker host, skipping the process of pushing to an intermediate registry.
I don't really like repeating stuff, so this process might sound familiar to you:
- Build image
- Push image
- Go to vps
- Pull image
Using transfer this boils down to:
- Build image
Pushtransfer image
And the image is now available on your remote host.
Transfer contains two components: a service (preconfigured registry server) and a CLI. The service enables you to push images with layer caching and all the good stuff registry has, and CLI adds some commands to your docker client to push images and manage the service instance.
Transfer builds directly from docker/distribution
source repository, it just adds a new go package before the build, that acts as a notification handler (so it knows when an image gets pushed - this is where the image gets restored on the host machine). It also enables htpasswd
authentication by default, and users can be managed through the CLI.
The CLI can act as a standalone CLI or as a docker plugin. It allows you to push and manage the transfer service with simple commands.
A full installation process will be available through the CLI, but for now it's recommended to run it through a docker-compose
file.
version: "3.7"
# Services
services:
# Registry
registry:
image: wolfulus/transfer:v0.0.2
restart: unless-stopped
ports:
# "PUBLIC:5000"
- "5000:5000"
environment:
# This should match the (public) port above
# The container port will always run on port 5000
TRANSFER_SERVICE_PORT: "5000"
TRANSFER_MANAGEMENT_USERNAME: "wolfulus"
TRANSFER_MANAGEMENT_PASSWORD: "yourpassword"
labels:
# Required for service detection
- com.wolfulus.transfer.version=v0.0.2
- com.wolfulus.transfer.managed=no
volumes:
# Contains the htpasswd file
- ./data/auth/:/data/auth/
# Stores the layer cache
- ./data/registry/:/var/lib/registry/
# Required to interact with docker
- /var/run/docker.sock:/var/run/docker.sock
Download the CLI release from GitHub that matches the service you installed on the server. The docker-transfer
executable should be put into your ~/.docker/cli-plugins
directory and permission set to +x
. On windows (Docker for Windows), the executable should be put in C:\Users\<your-user>\.docker\cli-plugins
.
There are no automatic installation scripts right now.
NOTE: you should do this for both the server and the client.
You can login to your registry (just make sure the service port is exposed and accessible before trying to)
docker login service.address:5000
This step is optional, but you can create an alias on your CLIENT machine using
docker transfer alias vps service.address:5000
Now whenever you want to push an image, you can target vps
instead of service.address:5000
. This is very useful when dealing with IP addresses and ports.
Make sure you have an image to transfer to the target machine and push it to your host using docker transfer image
command.
Usage:
docker transfer image host image[:tag]
For example (using the above alias):
docker transfer image vps nginx
After pushing, the image will be available on the host as nginx
On your host machine (assuming you didn't have an nginx machine there yet), check if the image got restored with docker image ls | grep nginx
:shrugs: