cleanup
This commit is contained in:
parent
c14c57e182
commit
ac6aa468f5
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.env
|
||||||
28
README.md
28
README.md
@ -7,11 +7,29 @@ images.
|
|||||||
## Quickstart
|
## Quickstart
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ docker run -ti --rm ghcr.io/jswank/alpine-cli
|
docker run -ti --rm ghcr.io/jswank/alpine-cli
|
||||||
~ $ ^D
|
|
||||||
exit
|
|
||||||
|
|
||||||
$ just
|
|
||||||
~ $ ^D
|
~ $ ^D
|
||||||
exit
|
exit
|
||||||
```
|
```
|
||||||
|
|
||||||
|
A script, using [casey/just](https://github.com/casey/just') is in [bin/cli](bin/cli).
|
||||||
|
It can be used to quickly start an ephemeral (or persistent) container:
|
||||||
|
|
||||||
|
```console
|
||||||
|
bin/cli
|
||||||
|
~ $ ^D
|
||||||
|
exit
|
||||||
|
|
||||||
|
bin/cli persist
|
||||||
|
~ $ ls
|
||||||
|
~ $
|
||||||
|
exit
|
||||||
|
|
||||||
|
podman cp foo.json alpine-cli:/home/cli
|
||||||
|
|
||||||
|
bin/cli persist
|
||||||
|
~ $ ls
|
||||||
|
foo.json
|
||||||
|
~ $
|
||||||
|
exit
|
||||||
|
```
|
||||||
|
|||||||
25
bin/cli
Executable file
25
bin/cli
Executable file
@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/env -S just --working-directory . --justfile
|
||||||
|
|
||||||
|
image := "ghcr.io/jswank/alpine-cli:latest"
|
||||||
|
n := "cli"
|
||||||
|
|
||||||
|
# run
|
||||||
|
default: run
|
||||||
|
|
||||||
|
# run a temporary container based on {{image}}
|
||||||
|
@run:
|
||||||
|
podman run -ti --rm {{image}}
|
||||||
|
|
||||||
|
# run (or attach to) a perisent container {{n}}
|
||||||
|
persist:
|
||||||
|
#!/bin/sh
|
||||||
|
if [ $(podman ps --all --filter name="{{n}}" -q | wc -l) -gt 0 ]; then
|
||||||
|
podman start -i -a {{n}}
|
||||||
|
else
|
||||||
|
podman run -ti --name {{n}} ghcr.io/jswank/alpine-cli:latest
|
||||||
|
fi
|
||||||
|
|
||||||
|
# remove the persistent image
|
||||||
|
clean:
|
||||||
|
@ podman rm -f {{n}} >/dev/null 2>&1
|
||||||
|
|
||||||
26
cli
26
cli
@ -1,26 +0,0 @@
|
|||||||
#!/usr/bin/env -S just --working-directory . --justfile
|
|
||||||
|
|
||||||
image := "ghcr.io/jswank/alpine-cli:latest"
|
|
||||||
n := "alpine-cli"
|
|
||||||
|
|
||||||
# get a bash shell on a temporary container using {{image}}
|
|
||||||
all: run
|
|
||||||
|
|
||||||
# get a bash shell on a temporary container using {{image}}
|
|
||||||
run:
|
|
||||||
@ docker run -ti --rm {{image}}
|
|
||||||
|
|
||||||
# run (or attach to) a perisent container {{n}}
|
|
||||||
persist:
|
|
||||||
#!/bin/sh
|
|
||||||
already_running=$(docker ps --all --filter name={{n}} --format=json | wc -l )
|
|
||||||
if [[ $already_running -gt 0 ]]; then
|
|
||||||
docker start -i {{n}}
|
|
||||||
else
|
|
||||||
docker run -ti --name {{n}} {{image}}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# remove the persistent image
|
|
||||||
clean:
|
|
||||||
@ docker rm -f {{n}} >/dev/null 2>&1
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user