|||

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

Tag

Test and build your image on LOCAL. Tag it with the localhost address and registry port (127.0.0.1:5000/)

docker tag imagename:version 127.0.0.1:5000/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 127.0.0.1:5000:127.0.0.1:5000 username@remotedocker 

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

ssh -L -fN 127.0.0.1:5000:127.0.0.1:5000 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 127.0.0.1:5000:127.0.0.1:5000 username@remotedocker sleep 120 

Push Image to REMOTE

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

docker push 127.0.0.1:5000/imagename:version

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

or

ssh username@remotedocker docker run -d --name imagename-version 127.0.0.1:5000/imagename:version
Up next DMented 'zine for DM's and Character Sheets for Players Python Notes
Latest posts Learning Graphical Design Python Notes Deploy to a Remote Docker registry DMented 'zine for DM's and Character Sheets for Players Online Security Now 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 Raspberry PI Zero quickstart Notes on Van Life Ubuntu 16.04 or 18.04 Installing Dropbox on Arch Linux Arch Linux Notes About Knives, Mainly Sharpening ENS Environment Notification System