===== Deploy Containers=====
need to ensure you have everything installed
dnf install container-tools
use command **podman ** to interface with **runc** (the container engine)
some podman commands
^ podman info | gives configuration details for containers |
^ podman ps | shows containers that are currently running for your user account use **-a** to see even stopped containers|
^ podman image inspect | used ti inspect an image tarfile |
^ podman build | Build a container image with a container file |
^ podman run | Run a command in a new container|
^ podman images | List images in local storage |
^ podman inspect | Display configuration of a container, image, volume, network, or pod |
^ podman pull | Download an image from a registry |
^ podman cp | Copy files or directories between a container and the local file system |
^ podman exec |Execute a command in a running container |
^ podman rm | Remove one or more containers |
^ podman rmi | Remove one or more locally stored images |
^ podman search | Search a registry for an image |
====Download a container Image from Registry===
First check that the podman utility is configured to search and downlaod containers from the Registry needed
podman info
use podman search image-wanted
to display a list of images on the configured registry
You can use the** skopeo inspect** command to examine different container image formats from a local directory or a remote registry without downloading the image
once you have the image you want you need to download it
podman pull registry.access.redhat.com/ubi8/python-38
use **podman images ** to verify
===Create container image from a container file===
you can use cat to see the containert file
one you are ok with it use
podman build -t NAME:TAG DIR
^ NAME | Name for the new image |
^ TAG | Tag for the new image. If the tag is not specified, then the image is automatically tagged as latest |
^ DIR | Path to the working directory. The container file must be in the working directory. If the working directory is the current directory, then you designate it by a dot (.). Use the -f flag to specify a different directory from the current one. |
once you have the container image you can then use it to run containers
===Running Containers===
a container can be in several states:
^ Created | A container that is created but is not started.|
^ Running | A container that is running with its processes. |
^ Stopped | A container with its processes stopped. |
^ Paused | A container with its processes paused. Not supported for rootless containers. |
^ Deleted | A container with its processes in a dead state. |
**NOTE** podman ps only shows the the running containers
To see all containers use
podman ps -a
You can create containers to run later
for example
[user@host ~]$ podman create --name python36 dd6ca291f097
c54c7ee281581c198cb96b07d78a0f94be083ae94dacbae69c05bd8cd354bbec
[user@host ~]$ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[user@host ~]$ podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c54c7ee28158 localhost/python36:1.0 /bin/bash -c slee... 5 seconds ago Created python36
you can also start a container and reference the image if image is not there it will download it
podman run -d quay.io/rdacosta/my_httpd:lattest
[user@host ~]$ podman start python36
python36
[user@host ~]$ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c54c7ee28158 localhost/python36:1.0 /bin/bash -c slee... 6 minutes ago Up 3 seconds ago python36
you can also interface with your container once it is running
**podman exec -it name-container process
**
for example
podman exec -it romantic_aryavhata bash
this will open a bash prompt
====Troubleshooting====
You can check if a container is running or not with
podman ps -a
if the container is listed as exited with code 1 then need to investigate a bit more
use
podman container logs container_name
you may need to pass extra variables for the container to start. Before you can do this you NEED to remove the failed container
podman rm container_name
then restart it with the -e option for example
[student@servera ~]$ podman run -d --name db_01 \
--network frontend \
-e MYSQL_USER=dev1 \
-e MYSQL_PASSWORD=devpass \
-e MYSQL_DATABASE=devdb \
-e MYSQL_ROOT_PASSWORD=redhat \
registry.lab.example.com/rhel8/mariadb-105