# tools docker and podman are two of the most commonly used cli tools for interacting with containers directly. podman uses much of the same command syntax as docker. in my day to day, I typically default to podman, as it is available on the machines I work on. # container images ## what is an image Containers are created from images that are typically hosted in a repository like Dockerhub or Quay.io. Many large companies will run their own registry. When referencing an image, the format typically follows the below convention: ### fully qualifed image reference > [!CODE] > <mark style="background: #FFB8EBA6;">my-registry</mark>/<mark style="background: #ABF7F7A6;">owner</mark>/<mark style="background: #D2B3FFA6;">my-image</mark>:<mark style="background: #BBFABBA6;">tag</mark> - <mark style="background: #FFB8EBA6;">a registry</mark> can be fully qualified or can be referenced by a short name if configured in `reigstries.conf` - <mark style="background: #ABF7F7A6;">the owner</mark> of an image can be an organization or a single user - <mark style="background: #D2B3FFA6;">name of your image</mark> - a <mark style="background: #BBFABBA6;">tag</mark> allows different versions of an image to be published, commonly used for different versions. defaults to `latest` if not specified. To use podman to pull the official `latest` Python image from Dockerhub: ```bash podman pull index.docker.io/library/ubuntu:latest ``` ## what is an imagestream Alternate to images which are more like a "signpost" to an image #### required fields - name - repository location - current SHA - previous SHA - desired tag of image stream #### use cases - can be tied to `builds` or `deployments` - can automatically trigger new redeployment of above resources when an image update is available using `triggers` # starting a container locally To start a container: ```bash podman run my-little-image command (and options) ``` To start a container using RedHat's Universal Base Image and open a Bash terminal inside it: ```shell podman run -it ubi8/ubi:latest /bin/bash ``` ## helpful command flags - `-t (--tty)` allocates a psuedo-terminal to the container (allows you run commands interactively) - `-i (--interactive)` keeps STDIN open for a container. (use with -t to open a regular prompt in a container) - `-e (--env)` allows you to manually set environment variables inside a container. `--env-file $myfile` allows you to read in an existing file for the same purpose - `-d (--detach)` runs the container in the background. will print the ID of the container. # accessing an existing container We can use `exec` to run commands against a container that already exists: ```bash podman exec my-little-container -- ``` By combining the interactive, tty, and specificing bash as our command, we can open up an interactive bash terminal on our container: ```bash podman exec -it my-little-container /bin/bash ```