Containers Flashcards

1
Q

Explain what a container is and how to use one

A

A container is a set of one or more processes that are isolated from the rest of the system.

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

What 3 core technologies make up a container?

A

‣ Control Groups (cgroups) for resource management
‣ Namespaces for process isolation
‣ SELinux and Seccomp (Secure Computing mode) to enforce security boundaries

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

What are the 3 primary container tools used to manage, inspect and create containers?

A

‣ podman - directly manages containers and container images
‣ skopeo - inspects, copy, deletes and signs images
‣ buildah - creates new container images

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

Install container management tools and run a simple rootless container

A

yum module install container-tools

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

Start a rootless container

A

$ podman login registry.lab.example.com
$ podman pull registry.access.redhat.com/ubi8:latest
$ podman images
$ podman run -it registry.access.redhat.com/ubi8/ubi:latest
(-t is for –tty meaning pseudo-terminal)
(-i is for –interactive which means it accepts input)
(-d is for –detach which runs in the background)

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

Start a container named rhel8 with a bash terminal inside

A

$ podman run -it –name=rhel8 registry.access.redhat.com/ubi8/ubi /bin/bash

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

Run a container that removes itself once the command is completed

A

$ podman run –rm registry.access.redhat.com/ubi8/ubi cat /etc/os-release

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

Display container registry configuration

A

$ cat /etc/containers/registries.conf
or rootless is:
$ cat $HOME/.config/containers
(rootless settings override system)

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

Display podman configuration info

A

$ podman info

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

Find container images that start with “ubi” within a container registry

A

$ podman search registry.redhat.io/rhel8/ubi
or for longer descriptions:
$ podman search –notruc registry.access.redhat.com/rhel8/ubi

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

What is the offical Red Hat container catalog

A

https://access.redhat.com/containers

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

Inspect a remote container image

A

$ skopeo inspect docker://registry.redhat.io/rhel8/python-36

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

List locally stored container images

A

$ podman images

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

Inspect a locally stored container image

A

$ podman inspect registry.redhat.io/rhel8/python-38

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

Remove a locally stored container image

A

$ podman rmi registry.redhat.io/rhel8/python-36:latest

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

Create a detached container named mydb, publish port 3306, & declare file variables.

A

$ podman run -d –name mydb -e MYSQL_USER=user1 -e MYSQL_PASSWORD=redhat -e MYSQL_DATABASE=items -e MYSQL_ROOT_PASSWORD=redhat -p 3306:3306 registry.lab.example.com/rhel8/mariadb-103:1-102

17
Q

Confirm which containers are running

A

$ podman ps

18
Q

Connect to a premade mysql container & confirm the running databases

A

$ mysql -u user1 -p –port=3306 –host=127.0.0.1

mariadb[]> show databases;

19
Q

Stop a container

A

$ podman stop mydb

20
Q

Create a container running an Apache HTTP Server that starts an interactive bash shell

A

$ podman run –name myweb -it registry.lab.example.com/rhel8/httpd-24:1-105 /bin/bash

21
Q

Connect to a container and display the linux kernel release version

A

$ podman exec mysecondweb uname -sr

22
Q

Connect to a container using a previously used container ID & display the system load average

A

$ podman exec -l uptime

23
Q

Create a container named myquickweb that lists the contents of /etc/redhat-release & then auto- exits/deletes the container

A

$ podman run –name myquickweb –rm registry.lab.example.com/rhel8/httpd-24:1-105 cat /etc/redhat-release

24
Q

Stop & delete ALL containers

A

$ podman stop -a
$ podman rm -a
$ podman ps -a

25
Q

Create a detached container named myweb.
‣ Map port 8080 to 8080
‣ Mount ~/webcontent from host to /var/www
‣ Add Z as volume mount option (relabels directory and content to be SELINUX context container_file_t)

A

$ podman run -d –name myweb -p 8080:8080 -v ~/webcontent:/var/www:Z registry.lab.example.com/rhel8/httpd-24:1-98

26
Q

Change container behavior to allow systemd services to continue

A

$ loginctl enable-linger

$ loginctl show-user user

27
Q

Where are container systemd user services stored

A
$ ls ~/.config/systemd/user
myapp.service
$ systemctl --user daemon-reload
$ systemctl --user enable myapp.service
$ systemctl --user start myapp.service
28
Q

Create a systemd unit file for a container

A

$ cd ~/.config/systemd/user

$ podman generate systemd –name web –files –new

29
Q

Configure a container to start when the host machine starts

A

$ loginctl enable-linger

$ systemctl –user enable container-web

30
Q

Disable the start of a container when a host machine starts

A

$ systemctl –user disable container-web