Podman, Docker commands
Table of Contents
Here are some commands to setup and use Podman
Docker
Installing Docker
sudo apt install podman-docker
## View all the images:
docker images
## View running containers/pod:
#docker ps
#docker ps -a
## Run a constainer:
docker run container_name
## Downloading images:
docker pull image_name (alpine)
## Run command in a container:
docker container run alpine command (echo hello)
Checking os details:
cat /etc/os-release
All the way I was looking for this only(I think)
So docker was there already, but Redhat created the alternative to it called Podman. It is more featured docker.
Build on top of Podman there is this tool called Toolbox.
Installing Toolbox
sudo apt install podman-toolbox
Use toolbox:
toolbox
create Create a new toolbox container
enter Enter an existing toolbox container
list List all existing toolbox containers and images
Create a toolbox - in this case I’m using a custom image as base
$ toolbox create -i docker.io/akdev1l/ubuntu-toolbox:22.04 Created container: ubuntu-toolbox-22.04 Enter with: toolbox enter ubuntu-toolbox-22.04
toolbox create -i docker.io/akdev1l/ubuntu-toolbox:22.04 image_name
Enter the toolbox and do modifications
$ toolbox enter ubuntu-toolbox-22.04 ⬢$ sudo apt install -y neofetch
commit the changes:
$ podman commit ubuntu-toolbox-22.04 my-custom-image
You can now create new custom toolboxes by doing:
$ toolbox create -i my-custom-image
View all images in Podman:
podman images
Delete in toolbox:
# Delete container
toolbox rm container_id
# Delete image
toolbox rmi image_id
# Gives running pod's status
$>podman ps
# Lists all containers and images
$>toolbox list
- Start by creating a container
- Container is created by an image
- Choose a image (alpine)
# Toolbox will be created by your custom_name
toolbox create --image quay.io/toolbx-images/alpine-toolbox:3.17 your_custom_name
-i for image which is alpine
toolbox list
CONTAINER ID CONTAINER NAME CREATED STATUS IMAGE NAME
e1912fd59a57 alpine-toolbox-3.17 4 minutes ago running quay.io/toolbx-images/alpine-toolbox:3.17
Now you have a container named alpine-toolbox-3.17
- Enter the container!
toolbox enter alpine-toolbox-3.17
Install desired libraries or applications
Commit the changes to the container
podman commit container_name new_name
No output in podman seach item:
sudo nano /etc/containers/registries.conf
unqualified-search-registries=["registry.access.redhat.com", "registry.fedoraproject.org", "docker.io"]
Creating a backup
podman container stop container_name
# Commit and create a image of your container
podman container commit -p container_id backup_image_name
# Check it
toolbox list
# Create/export the image
podman save -o image_name.tar backup_image_name
# You can clean up if you want to
podman rmi ---
toolbox rm ---
Creating an image
podman commit container_name image_name
Restoring a backup
# Loading the file to podman
podman load -i image.tar
# Check it
toolbox list
# toolbox create --container new_container_name --image_name
# Check again
# Enter to the container
toolbox enter --container container_name
Error: Image used by seems to be invisible container
podman rmi localhost/unbuntoo_b
Error: Image used by 1d8bdeaa0192e9dd2d87fa08cc8cb92c2bac2195868537dec20eb48b5db0b475: image is in use by a container
podman rm --force 1d8bdeaa0192e
# then try