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, Docker created standard way to create images for Linux Containers.

Basic Docker Commands

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 Docker

  1. Install Docker Desktop

  2. Test it out

  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.