2026-09-05 13:10
Status:
Tags: IBM IBM Full Stack Software Developer Professional Certificate IBM - Introduction to Containers with Docker, Kubernetes & OpenShift Docker Kubernetes OpenShift Virtual Machines The Cloud DevOps Deployment
CDKO - Containers and Containerization
==Understand the Benefits of Containers
-
Introduction to Containers:
- Basically, deploying things to the cloud because of the reliability and given resource pool has become very common. The issue with deployment to a remote server however, is that you often times need to set up this entire VM that comes with a lot of extra things that you do not need and would tank you performance
- Therefore, what you can basically do to mitigate this is set up a container, which is basically a small, scalable and easily deploy-able VM, that you can configure to only really host the things that you would need
- This would basically also make it very standard to have the exact same function and resource taking in every single container
- Making containers for software super reliable, scalable, and efficient on resources
- A Container is a standard unit of software that encapsulates everything that programmers need to run, build, and ship an application
- It isolates things like the code, dependencies, libraries, binaries, and whatever else the software needs to run
- The actual infrastructure and underlying operating system is no longer really an issue, and you can really just take you application’s container and run it anywhere
- This includes things like from a physical to virtual environment, or even from a private cloud to a public or hybrid one
- Containers can be small, and are generally much smaller than an entire VM, allowing them to be started and stopped very quickly and easily
- Container Engines basically containerize the operating system and are responsible for actually running the containers
- This makes a container very lightweight, and has it require far less memory and other resources than the alternative of an entire VM
- This also makes each container separate from the others, meaning they can run different dependencies, and can even have multiple different containers running on the same machine
- Containers are independent of the operating system they are running on, and the operating system they themselves are running
- This therefore means you can have something like a Linux Container running just fine on windows, making it super easy to set up things like full-stack development
- Downsides
- There can be a very difficult thing with converting legacy monolithic applications into a container like system
- If you end up with MANY different containers it can be hard to manage such a large volume of them, like thousands
- There is also a security impact if the operating system that the containers are running, or are running on, is affected by some sort of malware
- Some popular container vendors and their use-cases in the image above
-
Introduction to Docker:
- Docker- made available to the public in the year 2013, it was made as an open platform for programmers to develop, ship, and run their programs using containers
- It became VERY popular with the dev community for the fact that it had a very simple architecture, was easily scalable, and was very portable as well, meaning it worked great in different environments and locations
- Docker actually separates the different applications from the infrastructure of the outer operating system, meaning that it can run your applications independent of the platform that the actual container runtime is running on
- Written in the GO programming Language docker uses some of the Linux Kernel’s feature to deliver the functionality that it does
- It uses namespace technology to provide an isolated workspace for your application called the container (think like the separate apps you have on the MidasCloud)
- For trying to run multiple different containers and images on a single machine, it creates a set of name spaces for every container and each aspect runts in a separate namespace with a limited access to the main outer container namespace
- Docker Add-Ons, due to how popular docker was, it has a bunch of new functionality that was basically added onto it, this being things like the
DockerCLIwhich is somewhat references in General Commands For Command Line Interfaces, as well as things like Docker-Compose allowing for the pulling of images and multiple containers in one VM instance - Docker Technologies things like
swarmandkuberneteswhich are covered in other parts of this course, and are generally ways to maximize the use of docker - Docker Methodologies basically the way that docker revolutionized product delivery and development in the form of microservices and optimization
-
Building and Running Container Images:
- First you create a
DockerFilewhich is a document that outlines the structures and the general dependencies and needed inter-workings for your container - This is then processed inside of the docker engine as it would get built and becomes basically an image which is sort of like a snapshot of the needed operating system based on the DockerFiles
- This image is then used to run the container in which the specifications are all drawn up and actually using resources
- This basically is a VERY basic docker file. The
FROMkeyword defines the base image, which in this case is something calledalpine, and then theCMDportion basically allows you to specify out a given command, this time being echo, which just prints out the text over to the terminal - You then build this docker file by running
docker build -t <appname>:v1 .where basically you use the docker CLI in order to build the image from the docker file, specifying things like the version, as well as the current directory which I can assume is the location of the DockerFile - This would basically send the entire process over to the background Docker Daemon process, which would build the image and the tag for that image as well (putting it in the directory)
- You can then check to see that the docker images have in fact been built simply by running
docker imagesinside of the CLI, this would show you the things like size of the image itself, the content size, the ID, and all other such things as listed above - Its good for verification of a lot of different things, like creation or references
- Once you have a valid image that you ended up getting from your DockerFile, you basically then run it using
docker run <appname>:v1or whatever you had as your name. - This then allows for the start up as your container, completing it’s functions as intended if the building of the image went properly and everything
- You can then also verify all of the running containers that you have using the
docker ps -acommand, which shows a large amount of data regarding the running images
-
Docker Objects:
-
Docker Objects
- Include things like DockerFile, Image, Container, Network, Storage Volume, & Plugins/Add-ons
-
DockerFile- is a text file, made simply with something like
nano DockerFileand it contains instructions needed to create an actual image -
You can create this docker from basically anywhere, a CLI or even a GUI
-
IMPORTANT INSTRUCTIONS
- FROM- must being with a from instruction, and this is what defines the base image, often from a public repo like an OS or a language like Node or GO
- RUN- this executes arbitrary commands
- CMD- defines default commands for container execution, basically what gets run whenever the image is created, and there should only ever be one of these
FROM node:22-alpine WORKDIR /app # better-sqlite3 needs these to compile its native binding during npm install RUN apk add --no-cache python3 make g++ COPY package*.json ./ RUN npm install --omit=dev COPY . . EXPOSE 3000 CMD ["node", "server.js"]- The Above is a REAL DockerFile used by the MidasCloud back-end for the obsidian portal registration
- You can see the base image is
FROM node:22-alpine, which is downloaded - You then basically have the working directory for this specific project, and meaning all of the real code and what not is in the /app directory
- You then have a
RUNinstruction which executes that command inside of the docker image, installing all of the dependencies, you even see theCOPY packge*.jsonas a means of copying both thepackage.json & package-lock.jsonfiles into the image so as to runnpm installand get all of the dependencies - You then basically copy all of the code from the local directory into the image, expose that bad boy on the port 3000,
- And then, in the CMD you run
node server.jswhich basically in turn sets up the node server back-end so shes listening - A Docker Image is basically a template that has instructions inside of itself for how the actual operating system that is the docker container should run and exist
- IT uses instructions from the
DockerFile, and creates these image layers for each of the instructions inside of the docker file - Whenever you run the image, you create a writable layer where the actual processes happen
- Layers can be shared to save bandwidth and disk spaces as well between different containers
- Each image has a Unique naming scheme which is basically something like
hostname/repository:tag - The host-name would identify the image registry
- The repository is a group of similar or congruent container images
- The tag then provides specific information about an image or it’s variation
- So something like
docker.io/ubunut:18.04would signify that this image comes from the host “Docker Hub Registry”, a main popular registry - The repository of: “ubuntu” then specifies the docker image itself, being that of the ubuntu operating system
- The then included tag 18.04 specifies the version of ubuntu that we are talking about instantiating
- A docker container is a running image inside of docker and is basically the real running virtual machine that can change data and state and perform operations and all of the good stuff
- It can also basically connect to different networks, attach to storage, or create an entirely new image based on a current state
- This is super useful because if you want to isolate the network of your container for security reasons then you totally can, or if you want to run something like a Media Server, you can point Docker over to a real mounted drive on your system that is not running docker, and it will be able to read from it as if it was a part of it’s own system
- This allows for data to persist and still continue on even if the docker container is lost or stopped which is really good, and makes the size of the container super manageable as well
-
-
Docker Architecture:
-
- Basically, a given docker container is based on the idea of a client-server architecture, and is able to basically provide a complete and specialized image of an operating system
- This includes things like the client, the host, and the different registry components for the entire docker daemon as well
- Basically, you use the Cli to interact with the Docker Client which sends out commands to the Docker Host server, generally a process that would run inside of your great linux or whatever operating system
- The host server is also the daemon, a background process that listens out for different API requests, and when it finds one, it would do the thing that was instructed of it
- The docker daemon
dockerdis able to run, build, and distribute containers in a given registry, and that registry is basically just a collection of image files Dockerdalso hosts the inter-working structure of docker as well, ranging from things like images and containers to things like networks, namespaces, and storage- In the above I have been talking about the example where you have the Docker host basically installed on your given computer alongside the client side version of docker, however there are many different configurations of this
- While you can have the two on the same system, you can also have them on different systems, with you running a given client version of docker, a main centeral host server processing everything else
- Docker daemons can also communicate with other daemons in order to do things like pull images from the internet or something like that I assume
-
- Registries are places that store and distribute docker images. They can be either public, like
Docker-Hubwhich everyone can access, or private, like a given organization’s private registry which is made as such for security reasons - Registries are basically just databases or really storage places for these different images, and can be hosted and located either locally or on the cloud with a third-party provider
- These registries are updated whenever someone creates a docker file and builds the image, at which point they push it to whatever registry they want
- Local machines and cloud systems with access to the registry are then able to pull system images from said registry, and run them as containers using their own docker set up
-
Review of Docker Concepts and Understanding a DockerFile:
-
DockerFile- A text file that contains instructions for building a Docker image. It specifies the base image, sets the working directory, installs dependencies, copies application code, exposes ports, and defines commands to run the application.
-
Container- An instance of a Docker image that runs as a process on the host machine. Containers are lightweight, portable, and isolated, making them ideal for deploying and scaling applications.
-
Docker Image Storage- Docker images are stored in registries, which can be public or private. Public registries like Docker Hub host millions of images, while organizations often use private registries for security and control.
-
Where Do Images Exist?
- Local Machine: When you build a Docker image, it’s initially stored locally on your machine. You can list local Docker images using the docker images command.
- Registry: After building, you can push Docker images to a registry, making them accessible from anywhere with access to that registry.
# Use an official OpenJDK 21 image as the base image FROM openjdk:21-jdk-slim # Set a working directory inside the container WORKDIR /app # Label the image with metadata LABEL maintainer="Your Name <[email protected]>" LABEL version="1.0" LABEL description="A Java web application running in Docker" # Copy the compiled JAR file to the container COPY target/myapp.jar /app/myapp.jar # Expose port 8080 to allow external access EXPOSE 8080 # Run the application when the container starts CMD ["java", "-jar", "/app/myapp.jar"] # Health check to ensure the application is running HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \ CMD curl --fail http://localhost:8080/health || exit 1 -
==Summary
- A container is a software unit that packages everything needed to build, ship, and run an application.
- Containers help reduce deployment time and costs, improve resource utilization, automate processes, and support next-generation applications such as microservices.
- Popular container technologies and vendors include Docker, Podman, LXC, and Vagrant.
- Docker is an open platform used to develop, ship, and run applications in containers.
- Docker containers may not be the best fit for monolithic applications or workloads with strict high-performance or security requirements.
- Docker architecture consists of three main components: the Docker client, the Docker host, and the container registry.
- The Docker host manages Docker objects such as Dockerfiles, images, containers, networks, storage volumes, plugins, and add-ons.
- Docker networks help isolate communication between containers.
- Docker uses volumes and bind mounts to persist data even after containers stop running.
- Plugins, including storage plugins, enable Docker to connect with external storage platforms.
==Cheat Sheet: Docker CLI
| Command | Description |
|---|---|
| curl localhost description | Pings the application. |
| docker build | Builds an image from a Dockerfile. |
| docker build . -t | Builds the image and tags the image id. |
| docker container rm | Removes a container. |
| docker images | Lists the images. |
| docker ps | Lists the containers. |
| docker ps -a description | Lists the containers that ran and exited successfully. |
| docker pull | Pulls the latest image or repository from a registry. |
| docker push | Pushes an image or a repository to a registry. |
| docker run | Runs a command in a new container. |
| docker run -p | Runs the container by publishing the ports. |
| docker stop | Stops one or more running containers. |
| docker stop $(docker ps -q) | Stops all running containers. |
| docker tag | Creates a tag for a target image that refers to a source image. |
| docker —version | Displays the version of the Docker CLI. |
| exit | Closes the terminal session. |
| export MY_NAMESPACE | Exports a namespace as an environment variable. |
| git clone | Clones the git repository that contains the artifacts needed. |
| ibmcloud cr images | Lists images in the IBM Cloud Container Registry. |
| ibmcloud cr login | Logs your local Docker daemon into IBM Cloud Container Registry. |
| ibmcloud cr namespaces | Views the namespaces you have access to. |
| ibmcloud cr region-set | Ensures that you are targeting the region appropriate to your cloud account. |
| ibmcloud target | Provides information about the account you’re targeting. |
| ibmcloud version | Displays the version of the IBM Cloud CLI. |
| ls | Lists the contents of this directory to see the artifacts. |
==Glossary
| Term | Definition |
|---|---|
| Agile | is an iterative approach to project management and software development that helps teams deliver value to their customers faster and with fewer issues. |
| Client-server architecture | is a distributed application structure that partitions tasks or workloads between the providers of a resource or service, called servers, and service requesters, called clients. |
| A container | powered by the containerization engine, is a standard unit of software that encapsulates the application code, runtime, system tools, system libraries, and settings necessary for programmers to efficiently build, ship and run applications. |
| Container Registry | Used for the storage and distribution of named container images. While many features can be built on top of a registry, its most basic functions are to store images and retrieve them. |
| CI/CD pipelines | A continuous integration and continuous deployment (CI/CD) pipeline is a series of steps that must be performed in order to deliver a new version of software. CI/CD pipelines are a practice focused on improving software delivery throughout the software development life cycle via automation. |
| Cloud native | A cloud-native application is a program that is designed for a cloud computing architecture. These applications are run and hosted in the cloud and are designed to capitalize on the inherent characteristics of a cloud computing software delivery model. |
| Daemon-less | A container runtime that does not run any specific program (daemon) to create objects, such as images, containers, networks, and volumes. |
| DevOps | is a set of practices, tools, and a cultural philosophy that automate and integrate the processes between software development and IT teams. |
| Docker | An open container platform for developing, shipping and running applications in containers. |
| A Dockerfile | is a text document that contains all the commands you would normally execute manually in order to build a Docker image. Docker can build images automatically by reading the instructions from a Dockerfile. |
| Docker client | is the primary way that many Docker users interact with Docker. When you use commands such as docker run, the client sends these commands to dockerd, which carries them out. The docker command uses the Docker API. The Docker client can communicate with more than one daemon. |
| Docker Command Line Interface (CLI) | The Docker client provides a command line interface (CLI) that allows you to issue build, run, and stop application commands to a Docker daemon. |
| Docker daemon (dockerd) | creates and manages Docker objects, such as images, containers, networks, and volumes. |
| Docker Hub | is the world’s easiest way to create, manage, and deliver your team’s container applications. |
| Docker localhost | Docker provides a host network which lets containers share your host’s networking stack. This approach means that a localhost in a container resolves to the physical host, instead of the container itself. |
| Docker remote host | A remote Docker host is a machine, inside or outside our local network which is running a Docker Engine and has ports exposed for querying the Engine API. |
| Docker networks | help isolate container communications. |
| Docker plugins | such as a storage plugin, provides the ability to connect external storage platforms. |
| Docker storage | uses volumes and bind mounts to persist data even after a running container is stopped. |
| LXC | LinuX Containers is a OS-level virtualization technology that allows creation and running of multiple isolated Linux virtual environments (VE) on a single control host. |
| IBM Cloud Container Registry | stores and distributes container images in a fully managed private registry. |
| Image | An immutable file that contains the source code, libraries, and dependencies that are necessary for an application to run. Images are templates or blueprints for a container. |
| Immutability | Images are read-only; if you change an image, you create a new image. |
| Microservices | are a cloud-native architectural approach in which a single application contains many loosely coupled and independently deployable smaller components or services. |
| Namespace | A Linux namespace is a Linux kernel feature that isolates and virtualizes system resources. Processes which are restricted to a namespace can only interact with resources or processes that are part of the same namespace. Namespaces are an important part of Docker’s isolation model. Namespaces exist for each type of resource, including networking, storage, processes, hostname control and others. |
| Operating System Virtualization | OS-level virtualization is an operating system paradigm in which the kernel allows the existence of multiple isolated user space instances, called containers, zones, virtual private servers, partitions, virtual environments, virtual kernels, or jails. |
| Private Registry | Restricts access to images so that only authorized users can view and use them. |
| REST API | A REST API (also known as RESTful API) is an application programming interface (API or web API) that conforms to the constraints of REST architectural style and allows for interaction with RESTful web services. |
| Registry | is a hosted service containing repositories of images which responds to the Registry API. |
| Repository | is a set of Docker images. A repository can be shared by pushing it to a registry server. The different images in the repository can be labelled using tags. |
| Server Virtualization | Server virtualization is the process of dividing a physical server into multiple unique and isolated virtual servers by means of a software application. Each virtual server can run its own operating systems independently. |
| Serverless | is a cloud-native development model that allows developers to build and run applications without having to manage servers. |
| Tag | A tag is a label applied to a Docker image in a repository. Tags are how various images in a repository are distinguished from each other. |



















