CentOS 7
Sponsored Link

Podman : Install2018/08/30

 
Install Container management tool Podman.
It's possible to use the same ease of use of Docker Cli and also Podman does not need specific Service Daemon.
[1] Install Podman.
[root@dlp ~]#
yum -y install podman
[2] This is the basic usage for Podman.
# pull image

[root@dlp ~]#
podman pull centos

[root@dlp ~]#
podman images

REPOSITORY                 TAG      IMAGE ID       CREATED       SIZE
docker.io/library/centos   latest   5182e96772bf   3 weeks ago   208MB

# run command inside container

[root@dlp ~]#
podman run centos /bin/echo "Welcome to the Podman World"

Welcome to the Podman World
# enter interactive session

[root@dlp ~]#
podman run -it centos bash

[root@bd11108ed4a3 /]#
[root@bd11108ed4a3 /]#
exit

[root@dlp ~]#
# commit image

[root@dlp ~]#
podman run centos bash -c "yum -y install httpd"

[root@dlp ~]#
podman commit $(podman ps -a | sed -n 2p | awk '{print $1}') my-httpd

[root@dlp ~]#
podman images

REPOSITORY                 TAG      IMAGE ID       CREATED          SIZE
localhost/my-httpd         latest   314fc5b0d003   16 seconds ago   335MB
docker.io/library/centos   latest   5182e96772bf   3 weeks ago      208MB

# run on background

[root@dlp ~]#
podman run -dt -p 80:80 localhost/my-httpd /usr/sbin/apachectl -D FOREGROUND

[root@dlp ~]#
podman ps

CONTAINER ID   IMAGE                       COMMAND                  CREATED         STATUS             PORTS                                    NAMES
d6ff4ee4e63a   localhost/my-httpd:latest   /usr/sbin/apachectl...   4 seconds ago   Up 3 seconds ago   0.0.0.0:80->80/udp, 0.0.0.0:80->80/tcp   gracious_wiles
[root@dlp ~]#
podman exec -it d6ff4ee4e63a bash -c 'echo "Hello Podman" > /var/www/html/index.html'

[root@dlp ~]#
podman inspect -l | grep \"IPAddress

            "IPAddress": "10.88.0.15",
[root@dlp ~]#
curl 10.88.0.15

Hello Podman
[root@dlp ~]#
podman kill d6ff4ee4e63a

d6ff4ee4e63aa33312b6532261200b1b0fdd5ecff22d27ac64d7818605ca6f07

# mount latest container's filesystem

[root@dlp ~]#
podman mount $(podman ps -a | sed -n 2p | awk '{print $1}')

/var/lib/containers/storage/overlay/5903fff998e5aec08d4489febf4884008137055cc7b5d3a002b1ec4f532b5332/merged
[root@dlp ~]#
df -h

Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   26G  2.2G   24G   9% /
devtmpfs                 3.9G     0  3.9G   0% /dev
tmpfs                    3.9G     0  3.9G   0% /dev/shm
tmpfs                    3.9G  8.6M  3.9G   1% /run
tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/vda1               1014M  188M  827M  19% /boot
tmpfs                    799M     0  799M   0% /run/user/0
overlay                   26G  2.2G   24G   9% /var/lib/containers/storage/overlay/5903fff998e5aec08d4489febf4884008137055cc7b5d3a002b1ec4f532b5332/merged

# unmount

[root@dlp ~]#
podman umount $(podman ps -a | sed -n 2p | awk '{print $1}')
# search

[root@dlp ~]#
podman search nginx

INDEX        NAME                                 DESCRIPTION                                       STARS   OFFICIAL   AUTOMATED
docker.io    docker.io/library/nginx              Official build of Nginx.                          9436    [OK]
docker.io    docker.io/jwilder/nginx-proxy        Automated Nginx reverse proxy for docker con...   1393               [OK]

# build from Dockerfile

[root@dlp ~]#
cat > Dockerfile <<EOF

FROM centos
MAINTAINER ServerWorld <admin@srv.world>

RUN yum -y install httpd
RUN echo "Hello Podman" > /var/www/html/index.html

EXPOSE 80
CMD ["/usr/sbin/apachectl", "-D", "FOREGROUND"]
EOF 

[root@dlp ~]#
podman build -t my-httpd:latest .

[root@dlp ~]#
podman images

REPOSITORY                             TAG      IMAGE ID       CREATED             SIZE
localhost/my-httpd                     latest   49b78fbd4fb3   49 seconds ago      335MB
docker.io/library/centos               latest   5182e96772bf   3 weeks ago         208MB

# delere all containers (if delete specific one, specify container's ID or Name)

[root@dlp ~]#
podman rm --all

0f8091a39a45fe0ec0b21eefe76fed0bb12f4e915e92d9fa0c5731c8c66c5d4b
4d654b0eab1a1b75773cd74e13ac6c51ca8e563e1484ca679df5a6ff6b9514e7
52c5f532425f59a7447a8255a664d53f03c43d35261249d6a7eec4adeca45aee

# delere all images (if delete specific one, specify image's ID)

[root@dlp ~]#
podman rmi --all

Untagged: docker.io/library/centos:latest
314fc5b0d003953430967325517477af522f5df569c1537062e23875f226894f
18f01f6f77ef941f5b31dd007d113620cbb1939ac33d1922edce7d9d2c9ebad7
5182e96772bf11f4b912658e265dfe0db8bd314475443b6434ea708784192892
49b78fbd4fb359ff1c2fbb3a670ef6ac062f8e6b7126c15c920e2ba3f0c6c32e
Matched Content