Skip to content

Instantly share code, notes, and snippets.

@WesselAtWork
Last active January 18, 2023 10:33
Show Gist options
  • Select an option

  • Save WesselAtWork/0c9a5791fe167fe297b920e576d65ee6 to your computer and use it in GitHub Desktop.

Select an option

Save WesselAtWork/0c9a5791fe167fe297b920e576d65ee6 to your computer and use it in GitHub Desktop.
This is a template to turn (most) container applications into a windows commandline app.
@echo off
echo.
podman run --rm -v "%cd%":/app -w /app -i registry.io/application:latest %*

Podman Application Template

This is the alias template I generally use to turn container applications into commandline applications useable in windows terminal contexts.

Setup

  1. Change the registry.io line to what you want to use

    podman run --rm -v "%cd%":/bear -w /bear -it docker.io/grafana/grizzly:latest %*
  2. (optional) Use the built in user if your container application comes with it

    podman run --rm -u user -v "%cd%":/home/user/app -w /home/user/app -it registry.io/application:latest %*
  3. Change the name of the file to the cli application like grr.bat

  4. Place the file in a folder somewhere like C:\aliases

  5. Make sure this folder is in your system path. See this how-to for directions.

Pros

  • Works in pwsh, cmd, and vscode/vscodium!
  • Use cli applications that are not natively built or available for dos!
  • Keeps apps up to date with the latest tag! (Just watch your image count!)
  • Using the -i flag you can pipe data into your "fake" application on the command line!

Cons

  • Scoped to local dir
  • App prompt might not work corrctly (you will need to add the -t flag which might break the -i pipeing)

The main drawback is that you are scoped to the local directory you executed the program in.

This works

C:> podman-application ./local/file

This won't

C:> podman-application ../../i-can't-reach-above-the-cupboard.txt

Tips

How to refer to my home directory

You might want to mount a .config folder from your home directory under dos.

You can do so with the %USERPROFILE% variable

-v %USERPROFILE%\.aws:/root/.aws

See this if you have issues with your %USERPROFILE% pointing somewhare else

How to add self signed CA certs to your image.

This is posible for most images. Here I provide steps for Alpine based images.

Alpine

  1. Add your cert chain as seprate .pem encoded files to a workdir

    This is all the CA Roots and Intermeidiate CAs

    can also be formated as a .crt bundle

  2. Drop into a alpine terminal while mounting your workdir

    C:> podman run -v C:\workdir:/workdir --rm -it alpine:latest
  3. Copy your cert chain to /usr/local/share/ca-certificates/

    /> cp /workdir/* /usr/local/share/ca-certificates/
  4. Run update-ca-certificates(8)

    /> update-ca-certificates
  5. Retrive the /etc/ssl/certs/ca-certificates.crt

    /> cp /etc/ssl/certs/ca-certificates.crt /workdir/
  6. Put the ca-certificates.crt bundle from your C:\workdir somewhere on your computer like C:\containercerts\alpine

  7. Update your bash alias to mount the certifiacte bundle as RO in your images

    -v C:\containercerts\alpine\ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt:ro

    podman run --rm -v C:\containercerts\alpine\ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt:ro -v "%cd%":/app -w /app -i registry.io/application:latest %*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment