Search This Blog

Saturday, 29 February 2020

Creating a custom image with podman



$ sudo podman login quary.io
Username:
Password:
Login Succeeded!


$ sudo podman run -d --name official-httpd -p 8180:80 ImageName

$ sudo podman ps 

#Log into the container 

$ sudo podman exec -it ImageName /bin/bash

# Updating a HTML page inside the container

bash-4.4# echo "Modified Page" > /var/www/html/home.html

exit
exit

$ curl 127.0.0.1:8180/home.html

Modified Page

# To see the modified changes on container
$ sudo podman diff ImageNmae

$ sudo podman stop ImageName
$ sudo podman ps
$ sudo podman commit -a 'pyla' IMAGENAME New-Custom-ImageName

$ sudo podman images 

REPOSITORY                             TAG         IMAGE ID
locahost/New-Custom-ImageName         latest      aa9b9426327

registry.access.redhat.com/ImageName   7.7        5gecfc91c83


$ sudo podman tag New-Custom-ImageName quay.io/pyla/New-Custom-ImageName:v1.0

$ sudo podman push quay.io/pyla/New-Custom-ImageName:v1.0

$ sudo podman run -d --name test -p 8280:80 pyla/New-Custom-ImageName:v1.0

$ sudo podman ps

$ sudo podman curl http://localhost:8280/home.html

Modified Page 

Get the container IP address:

$ sudo podman inspect \
> -f '{{ .NetworkSettings.IPAddress }}' ContainerName
10.xx.x.x



Saturday, 22 February 2020

Managing Container Images with Podman

Configuring Registries in Podman

  • To configure registries for the podman command, we need to update the /etc/containers/registries.conf file. 
  • Edit the registries entry in the [registries.search] section, adding an entry to the values list. 
[registries.search]
registries = ["registry.access.redhat.com", "quay.io"] 
  • Secure connections to a registry require a trusted certificate.
  • To support insecure connections, add the registry name to the registries entry in [registries.insecure] section of /etc/containers/registries.conf file:
[registries.insecure]
registries = ['localhost:5000']


Accessing Registries

Searching for images in Registries

The podman search command finds images by image name, user name, or description from all the registries listed in the /etc/containers/registries.conf configuration file. 

$ sudo podman search [OPTIONS] <term>


Option:  --limit <number> 
Description: Limits the number of listed images per registry.

Option:  --filter <filter=value>
Description: Filter output based on conditions provided.
Supported filters are:
•stars=<number>:Show only images with at least this number of Stars.
•is-automated=<true|false>: Show only images automatically built.
•is-official=<true|false>: Show only images flagged as official.

Option: --tls-verify <true|false>
Description: Enables or disables HTTPS certificate validation for all used registries. true

Registry Authentication

$ sudo podman login -u username  -p password registry.access.redhat.com

Login Succeeded!

Pulling images

To pull container images from a registry, use the podman pull command

$ sudo podman pull [OPTIONS] [REGISTRY[:PORT]/]NAME[:TAG]

$ sudo podman pull rhscl/mysql-57-rhel7:5.7


By default, Podman stores container images in the /var/lib/containers/storage/overlay-images directory.

To list all the container images stored locally.

$ sudo podman images

To start a new container based on the rhscl/mysql-57-rhel7:5.7 image, use the following
command:

$ sudo podman run rhscl/mysql-57-rhel7:5.7

Saving and Loading Images

  • Existing images from the Podman local storage can be saved to a .tar file using the podman save command. 
  • The generated file is not a regular TAR archive; it contains image metadata and preserves the original image layers. 
  • Using this file, Podman can recreate the original image exactly as it was.

$ sudo podman save [-o FILE_NAME] IMAGE_NAME[:TAG]

The following example saves the previously downloaded MySQL container image from the
Red Hat Container Catalog to the mysql.tar file:

$ sudo podman save \
> -o mysql.tar registry.access.redhat.com/rhscl/mysql-57-rhel7:5.7

  • Use the .tar files generated by the save subcommand for backup purposes. 
  • To restore the container image, use the podman load command.
$ sudo podman load [-i FILE_NAME]

$ sudo podman load -i mysql.tar

  • To save disk space, compress the file generated by the save subcommand with Gzip using the --compress parameter. 
  • The load subcommand uses the gunzip command before importing the file to the local storage.

Deleting Images

To delete an image from the local storage, run the podman rmi command. 

$ sudo podman rmi [OPTIONS] IMAGE [IMAGE...]
  • Any updates to images in a registry are not automatically updated. 
  • The image must be removed and then pulled again to guarantee that the local storage has the latest version of an image.

Deleting all Images

To delete all images that are not used by any container

$ sudo podman rmi -a
  • The rmi subcommand has the --force option. 
  • This option forces the removal of an image even if that the image is used by several containers or these containers are running.

Modifying Images

podman commit command is the most straightforward approach to creating new images, it is not recommended because of the image size (commit keeps logs and process ID files in the captured layers), and the lack of change traceability.

sudo podman commit [OPTIONS] CONTAINER \
> [REPOSITORY[:PORT]/]IMAGE_NAME[:TAG]

Option Description
--author ""    Identifies who created the container image.
--message ""   Includes a commit message to the registry.
--format       Selects the format of the image. Valid options are                   oci and docker.

To find the ID of a running container in Podman

$ sudo podman ps
  • Eventually, administrators might customize the image and set the container to the desired state.
  • To identify which files were changed, created, or deleted since the container was started, use the diff subcommand. 
  • This subcommand only requires the container name or container ID

$ sudo podman diff mysql-basic

To retrieve the list of mounted files and directories for a running container, use the podman inspect command

$ sudo podman inspect \
> -f "{{range .Mounts}}{{println .Destination}}{{end}}" CONTAINER_NAME/ID

To commit the changes to another image, run the following command:

$ sudo podman commit mysql-basic mysql-custom

Tagging Images


$ sudo podman tag [OPTIONS] IMAGE[:TAG] \
> [REGISTRYHOST/][USERNAME/]NAME[:TAG]

$ sudo podman tag mysql-custom devops/mysql

$ sudo podman tag mysql-custom devops/mysql:snapshot

Removing Tags from Images

A single image can have multiple tags assigned using the podman tag command. To remove them, use the podman rmi command, as mentioned earlier:

$ sudo podman rmi devops/mysql:snapshot

Publishing Images to a Registry

$ sudo podman push [OPTIONS] IMAGE [DESTINATION]

For example to push the bitnami/nginx image to its repository

$ sudo podman push quay.io/bitnami/nginx


References

Saturday, 8 February 2020

Unix-like operating system commands

#help command to get Information About the Command

$ping --help

#The man command is used to display the manual page of a given command.

$man ping

#pwd command to get Current Working Directory

$pwd

#cd To change to a directory

pyla@pylaLP:~$ pwd
/home/pyla
pyla@pylaLP:~$ cd ../
pyla@pylaLP:/home$ pwd
/home


pyla@pylaLP:~/Documents$ pwd
/home/pyla/Documents
pyla@pylaLP:~/Documents$ cd ../../
pyla@pylaLP:/home$ pwd
/home

pyla@pylaLP:/home$

pyla@pylaLP:/home$ cd - #To change back to the previous working directory
/home/pyla/Documents
pyla@pylaLP:~/Documents$

#ls command to Listing directory contents
$ls

https://linuxize.com/post/basic-linux-commands/
https://www.guru99.com/must-know-linux-commands.html

Red Hat OpenShift plans


Friday, 7 February 2020

vSAN cluster displays 0 Bytes

https://kb.vmware.com/s/article/58928

Ansible_Notes

   ansible -i inventory.ini -m ping all   # inventory.ini it will ping to the hosts which are in inventory # ansible -i inventory.ini -m pin...