Skip to content

Containers

Containers are a standard way to package an application and all its dependencies so that it can be moved between environments and run without change. They work by hiding the differences between applications inside the container so that everything outside the container can be standardized.

For example, Podman and Docker have created a standard way to create images for Linux Containers.

Basic CLI Commands

Action Command
Check Podman version podman --version
Check host information podman info
List images podman images
Pull image podman pull <container-name/container-id>
Run image podman run <container-name/container-id>
List running containers podman ps
Inspect a container podman inspect <container-id>
Stop a running container podman stop <container-id>
Kill a running container podman kill <container-id"
Build Podman image podman build -t <image_name>:<tag> -f containerfile .
Push image podman push <image_name>:<tag>
Remove stopped containers podman rm <container-id>
Remove image podman rmi -f <image-name> or podman rmi -f <image-id>
Action Command
Get Docker version docker version
Run hello-world Container docker run hello-world
List Running Containers docker ps
Stop a container docker stop <container-name/container-id>
List Docker Images docker images
Login into registry docker login
Build an image docker build -t <image_name>:<tag> .
Inspect a docker object docker inspect <name/id>
Inspect a docker image docker inspect image <name/id>
Pull an image docker pull <image_name>:<tag>
Push an Image docker push <image_name>:<tag>
Remove a container docker rm <container-name/container-id>

Running the CLI

  1. a. RECOMMENDED: Download Podman here

    b. NOT RECOMMENDED: Brew Installation

    brew install podman
    

  2. Create and start your first podman machine

    podman machine init
    podman machine start
    

  3. Verify Podman installation

    podman info
    

  4. Test it out: Podman Introduction

  1. Install Docker Desktop here

  2. Test it out: Getting Started with Docker

  1. Install ibmcloud CLI

    curl -fsSL https://clis.cloud.ibm.com/install/osx | sh
    

  2. Verify installation

    ibmcloud help
    

  3. Configure environment. Go to cloud.ibm.com -> click on your profile -> Log into CLI and API and copy IBM Cloud CLI command. It will look something like this:

    ibmcloud login -a https://cloud.ibm.com -u passcode -p <password>
    

  4. Log into docker through IBM Cloud

    ibmcloud cr login --client docker
    

Activities

Task Description Link Time
IBM Container Registry Build and Deploy Run using IBM Container Registry IBM Container Registry 30 min
Docker Lab Running a Sample Application on Docker Docker Lab 30 min

Once you have completed these tasks, you should have a base understanding of containers and how to use Docker.