Deploy to a Remote Docker registry

I needed to spin up services on a remote docker instance; Configure the services and have them running in a minute. I plan to put up a full write-up once I have everything running smoothly… these are just the begining stages to get some processes functioning.

This is the solution I came up with for simply pushing to the remote registry without any fussing with ssl.

This assumes you are fully firewalled (except for port 22) and have ssh tunneling available on the REMOTE side.

Build Local, Push Remote


Test and build your image on LOCAL. Tag it with the localhost address and registry port (

docker tag imagename:version

Start Registry and Connect LOCAL to REMOTE

If a registry is not already running on REMOTE, use something like:

ssh [email protected] docker run -d -p 5000:5000 --restart=always --name registry -v /mnt/registry:/var/lib/registry registry:2

Then bind the tunnel from LOCAL to REMOTE:

ssh -L [email protected] 

To run in the background use -fN ### must kill manually ps -ef | grep ssh then kill pid

ssh -L -fN [email protected] 

To connect for a short period and avoid fiddling wiht manually killing the process send a sleep command to hold it open. This works great for scripts that may only need a few seconds to send something.

ssh -L -f [email protected] sleep 120 

Push Image to REMOTE

To push your LOCAL image to the REMOTE registry, run the docker push command:

docker push

This should push your image through the LOCAL port to the REMOTE host’s registry.

Run the rest of your commands to spin up services

Then run commands to deploy to the stack (git the stack.yml/docker-compose.yml on REMOTE and docker stack deploy’…)

ssh [email protected] git clone blahblah.git
ssh [email protected] cd blahblah && docker stack deploy -c stack.yml servicename


ssh [email protected] docker run -d --name imagename-version
Up next DMented 'zine for DM's and Character Sheets for Players Python Notes
Latest posts Recommended Tech 2022 Proxmox Notes Meow Wolf Financial Notes Cast a URL to a Chromecast Email List System Design Cards About Music, Finding the good stuff. Zines shirt designs Now Learning Graphical Design Python Notes Deploy to a Remote Docker registry DMented 'zine for DM's and Character Sheets for Players Online Security Find Notes Samba Notes Things worth noting My Software Friends Favorites Recommended Tech Elasticsearch Notes Book Notes APRS Notes vim notes Nmap Notes Bash Notes Raspberry PI Zero quickstart Ubuntu 16.04 or 18.04