Skip to content

Instantly share code, notes, and snippets.

Pulling all the images from a docker registry

Normally, this would be a bad idea. My use case was this, we had a private registry with all our images going back a while, badly needing to get cleaned up and purged, and I wanted to grab a archive first. We couldn't just ssh to the machine hosting the registry to back it up that way.

To pull an image we need to know the registry, repository, and tag.

Luckily getting a list of repositories in the registry is easy with curl and jq.

curl --user "$REG_USER:$REG_PASS" -H "Accept: application/json"   "https://$REGISTRY/v2/_catalog"  | jq -r '.repositories[]'
@DerekV
DerekV / ArchivingRemoteMavenRepo.md
Last active February 13, 2021 16:50
Cloning and archiving a remote maven repo

I had a need to grab a backup of a remove Maven repo, and then saving this to AWS s3 for backup / archival purposes. In my case, it was an Artifactory Online instance that hosted jars and other artifacts that we own, but we did not have ssh access.

This is published with the intent of providing some inspiration for your own solution, as well as notes for myself. If you have something to add that might be useful for others, please open a PR.

Authentication

This was tested against artifactory, which documents several ways to authenticate.
In my case I used a header with an API token, which is Artifactory specific. However for this Gist I will replace that with basic auth, which will work with (I think) a broader range of maven implementations such as Sonatype Nexus, and works with Artifactory as well.

@DerekV
DerekV / send_data_over_network.rs
Created September 19, 2016 13:16
Example of sending data over local network in rust
use std::thread;
use std::io;
use std::io::prelude::*;
use std::time::Duration;
use std::net::{TcpListener, TcpStream};
use std::fs::File;
fn handle_client(mut stream: TcpStream) -> io::Result<File> {
let buf: &mut [u8; 100] = &mut [0; 100];
let mut file = try!(File::create("foo"));
@DerekV
DerekV / picard_filename_script
Last active December 26, 2015 22:59
picard stuff
$if($eq($if2(%albumartistsort%,%albumartist%,%artistsort%,%artist%),Various Artists),$if2(%label%,%albumartistsort%,%albumartist%,%artistsort%,%artist%),$if2(%albumartistsort%,%albumartist%,%artistsort%,%artist%))/
$if2(%album%,_unknown release)/
$if($gt(%totaldiscs%,1),%discnumber%-$if2(%discsubtitle%-,),)$if($ne(%albumartist%,),$num(%tracknumber%,2) ,)$if(%_multiartist%,%artist%- ,)%title%
@DerekV
DerekV / randomCall.hs
Last active August 29, 2015 14:20
Do a network call at random intervals using a Poisson progression
import Network.HTTP
import Network.URI (parseURI)
import System.Random
import Control.Concurrent
typicalDelayInSecs = fromIntegral 5
rate = recip typicalDelayInSecs
import Data.Map (Map)
import Data.MultiSet (fromList, toOccurList)
import Control.Monad
-- http://lpaste.net/131001
data Pint something = Pint something | EmptyPint
deriving (Show, Eq)
data Drink = Water | Milk | Tea | Beer
deriving (Show, Eq)
@DerekV
DerekV / gitignores.bash
Last active September 2, 2023 20:06
Quickly build .gitignoreWorks with https://github.com/github/gitignore
#!/bin/bash
default_source=$HOME/.local/share
IFS=$'\n'
if [[ $# == 0 ]]
then
echo "Usage Example : "
echo " mkdir MyNewProject"
@DerekV
DerekV / notes
Last active December 13, 2015 17:29
emacs scripting... Wanting to get better at Emacs, so I'm going to save any interesting elisp snippets I get working here as I work
regex to insert a header above lines sharing a first letter
Query replace regexp (default \(^\([[:upper:]] \).*^J\(^\2.*^J\)*\) -> ^J^J\2^J^J\1):
@DerekV
DerekV / bash_oneliners.bash
Last active December 13, 2015 17:28
random clips and one-liners
# case one
for f in *; do git mv $f `echo $f | tr [:upper:] [:lower:] | sed "s/chart/bnftchart/"` ; done
# case two, w/ case-sensitivity work around
for f in *; do git mv $f $f.new; git mv $f.new `echo $f | tr [:upper:] [:lower:] ` ; done
@DerekV
DerekV / passByRefAlternatives.cpp
Created October 12, 2012 22:42
Pass by refrence, example with alternatives
#include <iostream>
#include <utility>
using namespace std;
void getHoursRate(double &hours, double &rate)
{
cout << "enter hours:" << endl;