Another Japan in the World

Jun Aruga's blog.

Install podman & useful podman commands

I would show you how to install podman the alternative docker. The difference between docker and podman is

  • docker: Running the docker daemon to operate the containers.
  • podman: Do not need to run a daemon to operate the containers. As a initial setting, users need to run it by root authority. But after a setting, they can use podman from user authority. That's useful.

How to install and run podman with rootless

On Fedora

$ sudo dnf install -y podman

Then to run podman from user authority, add below lines to the files

$ cat /etc/subuid
$ cat /etc/subgid

Useful podman commands

There a compatibility between them, just replacing docker something with podman something. But podman does not support docker-compose.

The specific useful commands too. --debug option for podman info is podman specific.

$ podman info --debug

How to remove not removed container images & useful docker commands

Before next blog for qemu-user-static. I would write some articles.

How to remove not removed container images

The subject is that I faced.

The reason is after upgrading a docker, the actual storage to manage containers were changed. Then docker image ls command could still see the containers. But docker rmi or docker system prune can not detect the containers to remove it internally.

  • A: A docker old version: actual storage is at /var/lib/docker/devicemapper
  • B: A docker new version: actual storage is at /var/lib/docker/overlay2.

The steps I did is 1. Remove "A" rpm packages of the old version. Then /var/lib/docker was kept not deleted. 2. Install "B" rpm packages of the new version.

So, when I faced this situation, what I did is blew steps.

$ sudo systemctl stop docker

$ sudo rm -rf /var/lib/docker

$ sudo systemctl start docker

When run systemctl start docker, the new /var/lib/docker is created in the process.

Useful docker commands

docker image ls -a

To show all the container images including intermediate images.

docker system prune -f -a --volumes

It is useful to remove all the container image. The created images often occupy your hard disk.

$ docker system prune --help

Usage:  docker system prune [OPTIONS]

Remove unused data

  -a, --all             Remove all unused images not just dangling ones
      --filter filter   Provide filter values (e.g. 'label=<key>=<value>')
  -f, --force           Do not prompt for confirmation
      --volumes         Prune volumes

docker info

Useful information such as a storage driver and registry.

docker version

To know the version.

docker image build --rm -t sample/foo .

image can be ommited. But I prefer to show it explicitly. When building, adding --rm is very important to reduce the container image size. But it seems the default is true for my docker.

$ docker image build --help
      --rm                      Remove intermediate containers after a successful build
                                (default true)

Adding namespace "sample" is important to distinguish current focusing domain.

docker container run --rm

In case to create a small container image. busybox is useful. container can be omitted. But I prefer to show it explicitly.

$ docker container run --rm -t busybox uname -a
Linux 29722d64ab62 5.0.5-200.fc29.x86_64 #1 SMP Wed Mar 27 20:58:04 UTC 2019 x86_64 GNU/Linux
$ docker container run --help
      --rm                             Automatically remove the container when it exits