Summary
In this post, we covered an introduction to docker containers and explained the concept of containerization through concepts illustration and a practical example. we also covered an configuring, building and running docker containers and explained the concept of running multiple docker containers together through docker-compose.
This post covers the answers for Intro to Docker and Intro to Containerisation room in TryHackMe.
What is Containerization
In computing terms, containerization is the process of packaging an application and the necessary resources (such as libraries and packages) required into one package named a container. The process of packaging applications together makes applications considerably portable and hassle-free to run.
Modern applications are often complex and usually depend on frameworks and libraries being installed on a device before the application can run. These dependencies can:
- Be difficult to install depending on the environment the application is running (some operating systems might not even support them!)
- Create difficulty for developers to diagnose and replicate faults, as it could be a problem with the application’s environment – not the application itself!
- Can often conflict with each other. For example, having multiple versions of Python to run different applications is a headache for the user, and an application may work with one version of Python and not another.
What are Docker Containers?
Docker is a relatively hassle-free, extensive and open source containerisation platform. The Docker ecosystem allows applications (images – we’ll come onto this in a later room) to be deployed, managed and shared with ease.
Working on Linux, Windows and MacOS, Docker is a smart choice for running applications. Applications can be published as “images” and shared with others. All that is required is pulling (downloading) the image and running it with Docker.
Docker employs the same technology used in containerisation to isolate applications into containers called the Docker Engine. The Docker Engine is essentially an API that runs on the host operating system, which communicates between the operating system and containers to access the system’s hardware (such as CPU, RAM, networking and disk)
Because of this, the Docker engine is extensive and allows you to do things like:
- Connect containers together (for example, a container running a web application and another container running a database)
- Export and import applications (images)
- Transfer files between the operating system and container
Docker uses the programming syntax YAML to allow developers to instruct how a container should be built and what is run. This is a significant reason why Docker is so portable and easy to debug; share the instructions, and it will build and run the same on any device that supports the Docker Engine.
Challenges Answers
What is the abbreviation of the programming syntax language that Docker uses?
Where was Docker first showcased?
What version of Unix had the first concepts of containerisation?
pull
a docker image, what would our command look like?If we wanted to list all images on a device running Docker, what would our command look like?
Let’s say we wanted to pull the image “tryhackme” (no quotations); what would our command look like?
Let’s say we wanted to pull the image “tryhackme” with the tag “1337” (no quotations). What would our command look like?
What would our command look like if we wanted to run a container interactively?
Note: Assume we are not specifying any image here.
What would our command look like if we wanted to run a container in “detached” mode?
Note: Assume we are not specifying any image here.
Let’s say we want to run a container that will run and bind a webserver on port 80. What would our command look like?
Note: Assume we are not specifying any image here.
How would we list all running containers?
Now, how would we list all containers (including stopped)?
What docker command would we use to build an image using a Dockerfile?
Let’s say we want to name this image; what argument would we use?
docker-compose
to start up a series of containers. What argument allows me to do this?I want to use docker-compose
to delete the series of containers. What argument allows me to do this?
What is the name of the .yml file that docker-compose
uses?
Note: for this question, you will need to include the .yml file extension in your answer
Use Docker to start a web server with the “webserver” image (no quotations). You will need to run the container with port 80.
After starting the container, try to connect to https://LAB_WEB_URL.p.thmlabs.com/ in your browser. What is the flag?