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 username@remotedocker 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 username@remotedocker 

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

ssh -L -fN username@remotedocker 

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 username@remotedocker 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 username@remotedocker git clone blahblah.git
ssh username@remotedocker cd blahblah && docker stack deploy -c stack.yml servicename


ssh username@remotedocker docker run -d --name imagename-version
Up next DMented 'zine for DM's and Character Sheets for Players Python Notes
Latest posts Financial Notes Welding Notes Cast a URL to a Chromecast Email List System Design Cards About Music, Finding the good stuff. “Richie Pan’s America” Font Airflow Notes 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 Kawasaki Vulcan S 650 Notes Honda Rebel 300 Notes Samba Notes Things worth noting My Software Friends Favorites Recommended Tech Elasticsearch Notes Book Notes APRS Notes vim notes Nmap Notes 4runner Notes Bash Notes