Skip to content

Docker

Docker logo Docker logo

Looking to learn Docker? This page is packed with project ideas that will help you get started. Whether you're a beginner or an experienced user, our projects cover a range of topics that will help you master Docker and build powerful containerized applications. Check out our project ideas today and take your Docker skills to the next level!

Getting Started

Before you can start working on any Docker projects below, make sure to add the dependency script to your workspace. This script will ensure that Docker and other necessary dependencies are installed and configured properly, so that you can get the most out of your Docker projects.

Docker dependency script
#!/bin/bash

# Install Docker
apt update
apt -y install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository -y 'deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable'
apt-cache policy docker-ce
apt -y install docker-ce
update-alternatives --set iptables /usr/sbin/iptables-legacy
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy


# Install docker compose
curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version

# Change the docker directory to persist in user home directory 
mkdir -p /home/developer/.docker
cat >/etc/docker/daemon.json <<EOL
{
    "data-root": "/home/developer/.docker",
    "builder": {
        "gc": {
        "defaultKeepStorage": "2GB",
        "enabled": true
        }
    }
}
EOL

dockerd&

Hello World

Before beginning this tutorial make sure you add the Docker dependency script to your Grader Than Workspace.

Get started with this introductory to docker tutorial.

What will we learn?

This tutorial provides a quick and easy-to-follow guide on how to run the Docker "hello-world" container using the command line interface. By the end of this tutorial you will know how to download and run the "hello-world" Docker image.

Run the container

Open your terminal and run the following command to download and run the "hello-world" Docker image:

docker run hello-world

You should now see output in your terminal that is similar to the output below:

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:63421b18c1443a9a85139225293fae7541fb40b7832d9deff80b6a9a75ce3604
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.
...

That's it! You have successfully run the Docker "hello-world" container.

Red Hat

Before beginning this tutorial make sure you add the Docker dependency script to your Grader Than Workspace.

Red Hat is a popular distribution of the Linux operating system that is known for its stability, security, and enterprise-grade support. It is based on the open-source Fedora distribution and is often used in business environments for server applications, cloud computing, and virtualization. Red Hat is known for its reliability, scalability, and security features, making it a popular choice for mission-critical applications. Red Hat provides commercial support and services to its customers, making it a popular choice for businesses that require enterprise-grade support for their IT infrastructure.

What will we learn?

This Red Hat tutorial provides a quick and easy-to-follow guide on how to run Red Hat 8 in Docker using a few commands in a terminal. It provides step-by-step instructions on how to:

  • Download the Red Hat image from Docker Hub

  • Start the Red Hat container in interactive mode.

  • Exit the container and start it again later.

Download the image

Open your terminal run the following command to download the latest Red Hat 8 image from Docker Hub:

docker pull redhat/ubi8:latest

Run the container

Once the download is complete, run the following command to start the Red Hat container:

docker run -it --name redhat redhat/ubi8:latest /bin/bash

This will start the Red Hat container in interactive mode, which allows you to enter commands and interact with the container from the terminal.

Run a command

You should now see the command prompt of the Red Hat container. You can enter commands here just like you would on a regular Linux system.

Below is a demonstration of the command to start the container, then we use the ls command to list files in the root directory:

❯ docker run -it --name redhat redhat/ubi8:latest /bin/bash

[root@f669da19f3ca /]# ls 
bin  boot  dev  etc  home  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
Exit interactive mode

To exit the container, type exit at the command prompt.

Start the container again

If you want to start the container again, run the following command:

docker start -i redhat

This will start the container in interactive mode again, with the same settings and files as before.

That's it! You have successfully run Red Hat in Docker using a few simple commands in a terminal.