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
-
a. RECOMMENDED: Download Podman here
b. NOT RECOMMENDED: Brew Installation
-
Create and start your first podman machine
-
Verify Podman installation
-
Test it out: Podman Introduction
-
Install Docker Desktop here
-
Test it out: Getting Started with Docker
-
Install ibmcloud CLI
-
Verify installation
-
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:
-
Log into docker through IBM Cloud
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.