In Part 9 of the Learning Linux blog series, we learned how to manage the basics of Linux Security systems.
In the final part 10, We will construct basic commands, and understand containers using Podman, and docker in the Linux Operating System.
- Manage and configure containers
- docker search nginx(Search images on docker.io repository),
- docker pull nginx:1.20.2(Pull the image locally),
- docker rmi nginx:1.20.2(remove image), docker images (see the list of images),
- docker run -d -p 8080:80 --name newwebserver nginx (create a container name newwebserver on port mapping 8080 on host and 80 on container with detached mode),
- docker ps --all (list all running or non-running containers) or docker container list, docker stop container name/id(Stop container),
- nc localhost 8080(To confirm if container is accessible on host port),
- Perform container management using commands such as podman and skopeo
- Installing skopeo: yum install skopeo
- Inspect repositories: skopeo inspect docker://registry.fedoraproject.org/fedora:latest
- Copying images: skopeo copy docker://quay.io/buildah/stable docker://registry.kodekloud.com/buidah, skopeo copy oci:busybox_ocilayout:latest dir:myemptydirectory
- Deleting Image: skopeo delete docker://localhost:5000/imagename:latest(delete image)
- Syncing registries: skopeo sync --src docker --dest dir registry.kodekloud.com/busybox /media/usb
- man skopeo(Manual page)
- Configure a container to start automatically as a systemd service and attach persistent storage
- mkdir -p ~/.config/systemd/user (Create dir structure to hold the folder for service unit files),
- podman run -d --name container_service -p 1025:8080 -v ~/container_storage:/var/www/html:Z registry.access.redhat.com/rhscl/httpd-24-rhel7 (Attaching a local folder to container),
- podman generate systemd --name container_service --files --new (Generating systemd service unit files for container),
- loginctl enable-linger <username>(To allow local user to run a service with systems),
- export XDG_RUNTIME_DIR=/run/user/$(id -u)
- systemctl --user daemon-reload,
- systemctl --user enable --now container-container_service.service (To allow container to run on boot),