EX188 Flashcards

(48 cards)

1
Q

See if DNS enabled on container

A

podman network inspect <NETWORK_NAME> - look for "dns_enabled": false,

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

Create podman network linked to eth0 interface

A

sudo podman network create -d macvlan -o parent=eth0 webnetwork

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

Access another container in slirp4netns

A

must use full host address and mapped host port

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

Inspect Mounts[0].Source

A

podman inspect --format="{{ (index .Mounts 0).Source}}" custom-advanced

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

Run container, bind to localhost, set environment variable, connect to multiple networks

A

podman run -p 127.0.0.1:8075:80 -e NAME='Red Hat' --net postgres-net,redis-net

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

Stop all containers, kill after 10 seconds

A

podman stop --all --time=10

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

Connect container to a network

A

podman network connect example-net my-container

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

See port mapping of a container

A

podman port my-app

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

Podman stores the credentials in the

A

${XDG_RUNTIME_DIR}/containers/auth.json

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

Login to OpenShift repo

A

oc login -u admin -p admin REPO_ADDR
podman login -u $(oc whoami) -p $(oc whoami -t) REPO_ADDR

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

Look for nginx in repositories

A

podman search nginx

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

Build image with single layer

A

podman build --squash-all -t localhost/squashed-all .

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

Podman repository config file

A

/etc/containers/registries.conf

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

Get information on remote docker image

A

skopeo inspect docker://registry.access.redhat.com/ubi9/nodejs-18

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

Copy image from remote repo to local file,ignore tls errors

A

skopeo copy --dest-tls-verify=false docker://registry.access.redhat.com/ubi9/nodejs-18 dir:/var/lib/images/nodejs-18

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

Containerfile: add multiple labels

A

LABEL name=”my-namespace/my-image-name” \
vendor=”My Company, Inc.” \
version=”1.2.3” \

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

Containerfile: Set env var according to argument during build

A

ARG VERSION=”1.16.8”
ENV VERSION=${VERSION}

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

Containerfile: Copy file from URL to container

A

ADD http://someserver.com/filename.pdf /var/www/html

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

Containerfile: Different container runtime commands, explain difference

A

ENTRYPOINT [“/usr/sbin/httpd”]
CMD [“-D”, “FOREGROUND”]

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

Pass argument during image build

A

podman build --build-arg VERSION=2.0.0

21
Q

Containerfile: Create user for rootless container run (inside a container)

A

RUN adduser --no-create-home --system --shell /usr/sbin/nologin python-server

22
Q

Setup build stage, copy file from it later (and change permissions) on

A

FROM nodejs-14:1 as builder

COPY --from=builder --chown=default /app/numbers.txt materials/numbers.txt

23
Q

Podman defines the allowed user and group ID ranges in

A

/etc/subuid and /etc/subgid files

24
Q

Add user and group ID ranges

A

sudo usermod --add-subuids 100000-165535 --add-subgids 100000-165535 student
podman system migrate

25
See user / group ID mappings inside a container
sudo podman exec root-gitea cat /proc/self/uid_map /proc/self/gid_map
26
Allow bind to port 80 and higher.
sudo sysctl -w "net.ipv4.ip_unprivileged_port_start=79"
27
Set group IDs that are allowed to use the ping utility
`sudo sysctl -w "net.ipv4.ping_group_range=0 2000000"`
28
See image layers
podman image tree ubi-httpd
29
mount read only directory to container
podman run --volume /www:/var/www/html:ro httpd-24
30
mount directory with selinux errors (explain flags)
podman run -v ./SQL_FILE:/tmp/SQL_FILE:Z - Lower case `z` lets different containers share access to a bind mount. - Upper case `Z` provides the container with exclusive access to the bind mount.
31
Backup, restore backup of a volume
`podman volume export http_data --output web_data.tar.gz` `podman volume import http_data web_data.tar.gz`
32
Run container with temporary volume
`podman run --mount type=tmpfs,tmpfs-size=512M,destination=/var/lib/pgsql/data httpd-24`
33
Get owner/group IDs of a folder inside of container.
`podman unshare ls -ln --directory ~/www`
34
See SElinux label on localfile system
ls -Zd /www
35
See ports used inside of container, explain flags
podman exec -it CONTAINER ss -pant -p # display the process using the socket -a # display listening and established connections -n # display numeric ports instead of mapped service names -t # display TCP sockets
36
See ports inside of container when the image does not include diagnostic tools
sudo nsenter -n -t CONTAINER_PID ss -pant
37
Compose: top level keywords
version services networks volumes
38
Compose: Empty network and external network
networks: app-net: {} db-net: external: true
39
Compose: Empty volume and external volume
volumes: db-vol: {} my-volume: external: true
40
Compose: Container depending on another container (database)
services: database-admin: depends_on: - database # start after the database container.
41
database service with postgress image, custom name, port mapping, environment variables, custom runtime command, attached to few networks and volume
``` services: database: # database container image: "registry.redhat.io/rhel9/postgresql-13" container_name: "appdev-postgresql" ports: - 3030:8080 environment: ACCOUNTS_SERVICE: http://accounts command: sh -c "COMMAND" networks: - app-net - db-net volumes: - db-vol:/var/lib/postgresql/data # ```
42
Re-create compose containers on start and anonymous volumes.
`podman-compose up --force-recreate -V`
43
Get podman events from 5 minutes ago, dont follow logs
`podman events --since 5m --stream=false --filter 'event=stop'`
44
Start podman container with secret stored in a file
`echo "Gr8P@ssword!" | podman secret create my-password -` `podman run --secret=my-password ubi9`
45
Path where podman secret is available
`/run/secrets/my_secret`
46
COMPOSE: Define file secret
``` secrets: my_secret: file: ./my_secret.txt ```
47
Install podman compose
`pip3 install podman-compose`
48