Howto podman: Difference between revisions

From Vidalinux Wiki
Jump to navigation Jump to search
Line 21: Line 21:
list containers that are running or have exited:
list containers that are running or have exited:
  podman ps -a
  podman ps -a
remove a container image by its image:
remove a local container image by its image:
  podman rmi docker.io/library/almalinux:8
  podman rmi docker.io/library/almalinux:9
pull container image from docker.io:
pull a remote container image from docker.io:
  podman pull docker.io/library/almalinux:9
  podman pull docker.io/library/almalinux:9
list all local images:
list all local images:
  podman images
  podman images
display information about how an image was built
display information about how an image was built:
  podman history docker.io/library/almalinux:9
  podman history docker.io/library/almalinux:9
log in to a remote registry:
log in to a remote registry:
  podman login registryURL -u username -p password
  podman login registryURL -u username -p password
pull an image from a remote registry:
pull an image from a remote registry:
  podman pull registry/username/image:tag
  podman pull docker.io/library/almalinux:9
search local cache and remote registries for images:
search local cache and remote registries for images:
  podman search searchString
  podman search searchstring
log out of the current remote registry
log out of the current remote registry
  podman logout
  podman logout
create a new image based on the current state of a running container:
create a new image based on the current state of a running container:
  podman commit container mynewimage:latest
  podman commit container mynewimage:tag
create (but don’t start) a container from an image:
create (but don’t start) a container from an image:
  podman create docker.io/library/almalinux:9
  podman create docker.io/library/almalinux:9

Revision as of 01:02, 31 January 2023

install podman archlinux

install podman packages:

pacman -Syu podman podman-compose 

install podman centos/almalinux/rocky

install podman packages:

yum -y install podman

install podman-compose:

curl -o /usr/local/bin/podman-compose https://raw.githubusercontent.com/containers/podman-compose/devel/podman_compose.py
chmod +x /usr/local/bin/podman-compose

install podman debian/ubuntu

install podman packages:

apt-get -y install podman

install podman-compose:

curl -o /usr/local/bin/podman-compose https://raw.githubusercontent.com/containers/podman-compose/devel/podman_compose.py
chmod +x /usr/local/bin/podman-compose

commands

create container image from file:

podman build -f Dockerfile

list containers that are running or have exited:

podman ps -a

remove a local container image by its image:

podman rmi docker.io/library/almalinux:9

pull a remote container image from docker.io:

podman pull docker.io/library/almalinux:9

list all local images:

podman images

display information about how an image was built:

podman history docker.io/library/almalinux:9

log in to a remote registry:

podman login registryURL -u username -p password

pull an image from a remote registry:

podman pull docker.io/library/almalinux:9

search local cache and remote registries for images:

podman search searchstring

log out of the current remote registry

podman logout

create a new image based on the current state of a running container:

podman commit container mynewimage:tag

create (but don’t start) a container from an image:

podman create docker.io/library/almalinux:9

start an existing container from an image:

podman start container

restart an existing container:

podman restart container

stop a running container gracefully

podman stop container

send a signal to a running container

podman kill container

Remove a container (use -f if the container is running)

podman rm [-f] container

display a live stream of a container’s resource usage:

podman stats container 

return metadata about a running container:

podman inspect container

private local registry

compose file to create registry:

version: '3'

services:
  registry:
    restart: always
    image: registry:2
    ports:
    - "5000:5000"
    environment:
      REGISTRY_AUTH: htpasswd
      REGISTRY_AUTH_HTPASSWD_REALM: Registry
      REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd
      REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /data
    volumes:
      - ~/docker-registry/auth:/auth
      - ~/docker-registry/data:/data

create password file:

mkdir ~/docker-registry/auth -p 
podman run --rm --entrypoint htpasswd httpd:2 -Bbn testuser testpassword > ~/docker-registry/auth/htpasswd

add another user to registry:

podman run --rm --entrypoint htpasswd httpd:2 -Bbn testuser2 testpassword2 >> ~/docker-registry/auth/htpasswd

run the registry by executing:

podman-compose up -d

log in to a private registry:

podman login --tls-verify=false http://localhost:5000 -u testuser testpassword

logout from local registry:

podman logout http://localhost:5000