Using Podman to Build and Push an Image to a Container Registry

Mindwatering Incorporated

Author: Tripp W Black

Created: 05/28 at 03:17 PM

 

Category:
Linux, RH AAP
Docker
Reference

Task:
Use local workstation Podman to build from a local Containerfile and push to a registry.


Steps:
1. Create the image:
$ podman build <context_directory> -t <image_name>


2. Login to repository:
$ podman login <registry_url_path>
<enter username and password at prompts>

Notes:
- If <registry_url_path> is omitted, the first registry from registries.conf under the [registries.search] heading is used.
- It can also be done w/in an AAP workflow.


3. Push to repository:
$ podman push <image_name>


4. Logout of repository:
$ podman logout -all


RH AAP Playbook Example:
- Login, build, push, and logout of a quay.io registry:

- name: Login to quay.io using existing secret called password
  containers.podman.podman_login:
    username: user
    secret: secretpassword
    registry: quay.io
- name: Build and push an image using existing credentials
  containers.podman.podman_image:
    name: nginx
    path: /path/to/build/dir
    push: true
    push_args:
      dest: quay.io/namespacename
- name: Log out of quay.io
  podman_logout:
    registry: quay.io




previous page

×