Skip to content

Instantly share code, notes, and snippets.

@dallasmarlow
Created July 7, 2021 20:58
Show Gist options
  • Save dallasmarlow/786c6f8e0b27bd817daaff942b895ee3 to your computer and use it in GitHub Desktop.
Save dallasmarlow/786c6f8e0b27bd817daaff942b895ee3 to your computer and use it in GitHub Desktop.
docker fish scripts
#!/usr/bin/env fish
source ../include/env.fish
source ../include/build_and_push.fish
#!/usr/bin/env fish
docker build -t $DOCKER_TAG .
if test -z $SKIP_PUSH
docker push $DOCKER_TAG
end
#!/usr/bin/env fish
set DOCKER_REG nas.local:5000
set DOCKER_IMG (basename (pwd))
set DOCKER_TAG $DOCKER_REG/$DOCKER_IMG
#!/usr/bin/env fish
docker pull $DOCKER_TAG
#!/usr/bin/env fish
set CONTAINER_NAME registry
set DOCKER_TAG $CONTAINER_NAME:2
set MNT_PATH /mnt/docker-$CONTAINER_NAME
source ../include/pull.fish
source ../include/util.fish
terminate $CONTAINER_NAME
docker run \
--name=$CONTAINER_NAME \
--net=host -d \
-v $MNT_PATH:/var/lib/registry \
$DOCKER_TAG
#!/usr/bin/env fish
source ../include/env.fish
source ../include/pull.fish
source ../include/util.fish
set CONTAINER_NAME $DOCKER_IMG
terminate $CONTAINER_NAME
docker run \
--name=$CONTAINER_NAME \
--network=host -d \
$DOCKER_TAG
#!/usr/bin/env fish
function kill_if_running
for c in $argv
echo -n "container '$c' running? - "
docker inspect --format="{{.State.Running}}" $c | grep true
if test $status -eq 0
echo -n "killing container: "
docker kill $c
end
end
end
function rm_if_exists
for c in $argv
echo -n "container '$c' exist? - "
docker ps -a --format="{{.Names}}" | grep $c
if test $status -eq 0
echo -n "removing container: "
docker rm $c --force
end
end
end
function terminate
for c in $argv
kill_if_running $c
rm_if_exists $c
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment