Podman Flashcards

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
Q

mount a host directory to a container,

A

podman run -v /home/student/dbfiles:/var/lib/mysql rhmap47/mysql

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

List a container’s ports

A

podman port apache3

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

Where do to you configure registries use by podman?

A

/etc/containers/registries.conf

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

What is the format of image files when stored locally?

A

.tar

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

Syntax of the save command

A

podman save [-o FILE_NAME] IMAGE_NAME[:TAG]

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

How do you use container stored locally?

A

podman load -i mysql.tar

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

Delete image from local storage

A

podman rmi [OPTIONS] IMAGE [IMAGE…]

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

Delete all images that are not used by any container

A

podman rmi -a

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

Save container from registry

A

podman save -o mysql.tar registry.redhat.io/rhel8/mysql-80

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

Turn running container into new image

A

podman commit mysql-basic mysql-custom

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

Tag an image as latest

A

podman tag 0e3bbc2 fedora:latest

podman tag httpd myregistryhost:5000/fedora/httpd:v2

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

Tag a new image as snapshot

A

podman tag mysql-custom devops/mysql:snapshot

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

Untag an image

A

podman rmi devops/mysql:snapshot

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

Push image to registry

A

podman push quay.io/bitnami/nginx

39
Q

podman diff official-httpd

A

examine the differences in the container between the image and the new layer created by the container.

40
Q

Inspect changes on a container or image’s filesystem.

A

podman diff official-httpd

41
Q

Mysql image

A

rhel8/mysql-80

42
Q

Base image

A

ubi8/ubi:8.5

43
Q

List of all running containers in json

A

podman ps –all –format=json

44
Q

Create a network

A

podman network create

45
Q

List existing networks

A

podman network ls

46
Q

Outputs a detailed JSON object containing configuration data for the network.

A

podman network inspect

47
Q

Delete network

A

podman network rm

48
Q

Removes any networks that are not currently in use by any running containers

A

podman network prune

49
Q

Connects an already running container to or from an existing network.

A

podman network connect

50
Q

disconnects a container from a network

A

podman network disconnect

51
Q

creates a new container called my-container, which is connected to the example-net network

A

podman run -d –name my-container \
–net example-net container-image:latest

52
Q

creates a new container called double-connector that connects to both the postgres-net and redis-net networks

A

podman run -d –name double-connector \
–net postgres-net,redis-net \
container-image:latest

53
Q

connect existing container to the example-net network

A

podman network connect example-net my-container

54
Q

When using the default network, the domain name system (DNS) is disabled. True or False.

A

True
To use DNS, create a new Podman network and connect your containers to that network

55
Q

get private IP of container

A

podman inspect my-app \
-f ‘{{.NetworkSettings.Networks.apps.IPAddress}}’

56
Q

Start process cat in running container called httpd

A

podman exec httpd cat /etc/httpd/conf/httpd.conf

57
Q

find whether the container is running

A

podman inspect –format=’{{.State.Status}}’ httpd

58
Q

ubi image

A

ubi8/ubi:8.6

59
Q

python image

A

ubi8/python-39:latest

60
Q

nodejs image

A

ubi8/nodejs-16:1

61
Q

GO image

A

ubi8/go-toolset

62
Q

How to inspect remote image

A

use skopeo

63
Q

List servers of all images on your machine

A

podman image ls –format “{{.Repository}}”

64
Q

Inspect image to see which command it runs by default

A

podman image inspect simple-server \
–format=”{{.Config.Cmd}}”

65
Q

inspect the image layers

A

podman image tree ubi-httpd

66
Q

difference between volumes and binds

A

Volumes are data mounts managed by Podman. Bind mounts are data mounts managed by the user.

67
Q

attach volume using mount

A

–mount type=TYPE,source=/path/on/host,destination=/path/in/container

68
Q

values of type when using mount

A

bind for bind mounts.

volume for volume mounts.

tmpfs for creating memory-only, ephemeral mounts.

69
Q

create a new volume called http-data

A

podman volume create http-data

70
Q

Determine where a bind volume was mounted

A

podman volume inspect http-data

71
Q

Where does podman store bind volumes

A

$HOME/.local/share/containers/storage/volumes/

72
Q

Create a bind volume and mount it

A

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
Q

import data from a tar archive into an existing Podman volume

A

podman volume import http_data web_data.tar.gz

74
Q

export data from an existing Podman volume and save it as a tar archive

A

podman volume export http_data –output web_data.tar.gz

75
Q

Run postgres so that it stores data on an ephemeral loacation

A

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
Q

When would you use tmpfs

A

for performance

77
Q

Import data into postgres inside a container

A

podman exec -it DATABASE_CONTAINER \
psql -U DATABASE_USER -d DATABASE_NAME \
-f CONTAINER_PATH/SQL_FILE

78
Q

creates an ephemeral container to load data into a PostgreSQL database:

A

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
Q

export the database called DATABASE to a BACKUP_DUMP

A

podman exec POSTGRESQL_CONTAINER \
pg_dump -Fc DATABASE -f BACKUP_DUMP

80
Q

Explain the Z option in podman run volume command

A

Sets SELinux context for the container to have access to the host SQL_FILE.

81
Q

run the psql client in the same PostgreSQL container

A

podman exec -it persisting-pg12 \
psql -d rpi-store -c “select * from model”

82
Q

pant

A

-p: display the process using the socket

-a: display listening and established connections

-n: display IP addresses

-t: display TCP sockets

83
Q

get the container PID

A

podman inspect CONTAINER –format ‘{{.State.Pid}}’

84
Q

Execute a process in running container with a specific env variable

A

podman exec -e ENVIRONMENT=dev

85
Q

reload nginx

A

podman exec nginx nginx -s reload

86
Q

nginx config location

A

/etc/nginx/nginx.conf

87
Q

restart nginx container

A

podman restart nginx

88
Q

remove all containers, including running ones

A

podman rm –all –force

89
Q

Create podman link

A

ln -s /bin/podman pm
PATH=$PATH:.

90
Q

block pulling images from docker.io

A

Add this in /etc/containers/registeries.conf

location=”docker.io”
blocked=true

91
Q

Location of podman credentials after login

A

${XDG_RUNTIME_DIR}/containers/auth.json

92
Q

Decode content of auth.json

A

echo ZGV2ZWxvcGVyOmRldmVsb3Blcg== | base64 -d

93
Q

Alternative to podman images

A

podman image ls

94
Q

build an image with specific tag

A

podman build –file dir/Dockerfile –tag quay.io/open-sudo/argocd:4.5