Podman Flashcards

(94 cards)

1
Q

Search for images containing button

A

podman search button

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Download images containing button

A

podman pull button

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

List local images

A

podman images

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Run container ubi8/ubi:8.3 such that it prints ‘Hello word’

A

podman run ubi8/ubi:8.3 echo ‘Hello world!’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Explain the -d option

A

Run container image as a background process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Run bash on container ubi8/ubi:8.3

A

podman run -it ubi8/ubi:8.3 /bin/bash

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Run MySQL with image: registry.redhat.io/rhel8/mysql-80

A

podman run –name mysql-custom \
> -e MYSQL_USER=redhat -e MYSQL_PASSWORD=r3dh4t \
> -e MYSQL_ROOT_PASSWORD=r3dh4t \
> -d registry.redhat.io/rhel8/mysql-80

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Run container to set environment variable GREET and print it

A

podman run -e GREET=Hello -e NAME=RedHat \
> ubi8/ubi:8.3 printenv GREET NAME

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Run bash on a running container

A

podman exec -it mysql-basic /bin/bash

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Displays all actively running containers

A

podman ps

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Displays all running and stopped containers

A

podman ps -a

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Stop container my-httpd-container

A

podman stop my-httpd-container

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Kill container

A

podman kill my-httpd-container

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Restart container

A

podman restart my-httpd-container

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Remove container

A

podman rm my-httpd-container

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Restart container

A

podman restart my-httpd-container

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Delete all containers

A

podman rm -a

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Stop all containers

A

podman stop -a

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Login to container registry

A

podman login registry.redhat.io

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

View container logs

A

podman logs mysql-db

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Copy database file to mysql container.

A

podman cp ~/db.sql mysql:/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Execute sql query inplace in mysql container

A

podman exec mysql /bin/bash -c ‘mysql -uuser1 -pmypa55 -e “select * from items.Projects;”’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Explain podman unshare

A

provides a session to execute commands within the same user namespace as the process running inside the container

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Example unshare command

A

podman unshare chown -R 27:27 /home/student/dbfiles

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
mount a host directory to a container,
podman run -v /home/student/dbfiles:/var/lib/mysql rhmap47/mysql
26
List a container's ports
podman port apache3
27
Where do to you configure registries use by podman?
/etc/containers/registries.conf
28
What is the format of image files when stored locally?
.tar
29
Syntax of the save command
podman save [-o FILE_NAME] IMAGE_NAME[:TAG]
30
How do you use container stored locally?
podman load -i mysql.tar
31
Delete image from local storage
podman rmi [OPTIONS] IMAGE [IMAGE...]
32
Delete all images that are not used by any container
podman rmi -a
33
Save container from registry
podman save -o mysql.tar registry.redhat.io/rhel8/mysql-80
34
Turn running container into new image
podman commit mysql-basic mysql-custom
35
Tag an image as latest
podman tag 0e3bbc2 fedora:latest podman tag httpd myregistryhost:5000/fedora/httpd:v2
36
Tag a new image as snapshot
podman tag mysql-custom devops/mysql:snapshot
37
Untag an image
podman rmi devops/mysql:snapshot
38
Push image to registry
podman push quay.io/bitnami/nginx
39
podman diff official-httpd
examine the differences in the container between the image and the new layer created by the container.
40
Inspect changes on a container or image’s filesystem.
podman diff official-httpd
41
Mysql image
rhel8/mysql-80
42
Base image
ubi8/ubi:8.5
43
List of all running containers in json
podman ps --all --format=json
44
Create a network
podman network create
45
List existing networks
podman network ls
46
Outputs a detailed JSON object containing configuration data for the network.
podman network inspect
47
Delete network
podman network rm
48
Removes any networks that are not currently in use by any running containers
podman network prune
49
Connects an already running container to or from an existing network.
podman network connect
50
disconnects a container from a network
podman network disconnect
51
creates a new container called my-container, which is connected to the example-net network
podman run -d --name my-container \ --net example-net container-image:latest
52
creates a new container called double-connector that connects to both the postgres-net and redis-net networks
podman run -d --name double-connector \ --net postgres-net,redis-net \ container-image:latest
53
connect existing container to the example-net network
podman network connect example-net my-container
54
When using the default network, the domain name system (DNS) is disabled. True or False.
True To use DNS, create a new Podman network and connect your containers to that network
55
get private IP of container
podman inspect my-app \ -f '{{.NetworkSettings.Networks.apps.IPAddress}}'
56
Start process cat in running container called httpd
podman exec httpd cat /etc/httpd/conf/httpd.conf
57
find whether the container is running
podman inspect --format='{{.State.Status}}' httpd
58
ubi image
ubi8/ubi:8.6
59
python image
ubi8/python-39:latest
60
nodejs image
ubi8/nodejs-16:1
61
GO image
ubi8/go-toolset
62
How to inspect remote image
use skopeo
63
List servers of all images on your machine
podman image ls --format "{{.Repository}}"
64
Inspect image to see which command it runs by default
podman image inspect simple-server \ --format="{{.Config.Cmd}}"
65
inspect the image layers
podman image tree ubi-httpd
66
difference between volumes and binds
Volumes are data mounts managed by Podman. Bind mounts are data mounts managed by the user.
67
attach volume using mount
--mount type=TYPE,source=/path/on/host,destination=/path/in/container
68
values of type when using mount
bind for bind mounts. volume for volume mounts. tmpfs for creating memory-only, ephemeral mounts.
69
create a new volume called http-data
podman volume create http-data
70
Determine where a bind volume was mounted
podman volume inspect http-data
71
Where does podman store bind volumes
$HOME/.local/share/containers/storage/volumes/
72
Create a bind volume and mount it
1) podman volume create http-data 2) podman run -p 8080:8080 --volume http-data:/var/www/html \ registry.access.redhat.com/ubi8/httpd-24:latest
73
import data from a tar archive into an existing Podman volume
podman volume import http_data web_data.tar.gz
74
export data from an existing Podman volume and save it as a tar archive
podman volume export http_data --output web_data.tar.gz
75
Run postgres so that it stores data on an ephemeral loacation
podman run -e POSTGRESQL_ADMIN_PASSWORD=redhat --mount type=tmpfs,tmpfs-size=512M,destination=/var/lib/pgsql/data \ registry.redhat.io/rhel9/postgresql-13:1
76
When would you use tmpfs
for performance
77
Import data into postgres inside a container
podman exec -it DATABASE_CONTAINER \ psql -U DATABASE_USER -d DATABASE_NAME \ -f CONTAINER_PATH/SQL_FILE
78
creates an ephemeral container to load data into a PostgreSQL database:
podman run -it --rm \ -e PGPASSWORD=DATABASE_PASSWORD \ -v ./SQL_FILE:/tmp/SQL_FILE:Z \ --network DATABASE_NETWORK \ registry.redhat.io/rhel8/postgresql-12:1-113 \ psql -U DATABASE_USER -h DATABASE_CONTAINER \ -d DATABASE_NAME -f /tmp/SQL_FILE
79
export the database called DATABASE to a BACKUP_DUMP
podman exec POSTGRESQL_CONTAINER \ pg_dump -Fc DATABASE -f BACKUP_DUMP
80
Explain the Z option in podman run volume command
Sets SELinux context for the container to have access to the host SQL_FILE.
81
run the psql client in the same PostgreSQL container
podman exec -it persisting-pg12 \ psql -d rpi-store -c "select * from model"
82
pant
-p: display the process using the socket -a: display listening and established connections -n: display IP addresses -t: display TCP sockets
83
get the container PID
podman inspect CONTAINER --format '{{.State.Pid}}'
84
Execute a process in running container with a specific env variable
podman exec -e ENVIRONMENT=dev
85
reload nginx
podman exec nginx nginx -s reload
86
nginx config location
/etc/nginx/nginx.conf
87
restart nginx container
podman restart nginx
88
remove all containers, including running ones
podman rm --all --force
89
Create podman link
ln -s /bin/podman pm PATH=$PATH:.
90
block pulling images from docker.io
Add this in /etc/containers/registeries.conf location="docker.io" blocked=true
91
Location of podman credentials after login
${XDG_RUNTIME_DIR}/containers/auth.json
92
Decode content of auth.json
echo ZGV2ZWxvcGVyOmRldmVsb3Blcg== | base64 -d
93
Alternative to podman images
podman image ls
94
build an image with specific tag
podman build --file dir/Dockerfile --tag quay.io/open-sudo/argocd:4.5