Post

[THM Walkthrough] Intro to Docker

This is a full walkthrough with answers and explanations for the TryHackMe room "Intro to Docker".

[THM Walkthrough] Intro to Docker

Link to the room: https://tryhackme.com/room/introtodockerk8pdqk.

[Task 2] Basic Docker Syntax

If we wanted to pull a docker image, what would our command look like?

1
docker pull

Images can be downloaded using the docker pull command and providing the name of the image.

If we wanted to list all images on a device running Docker, what would our command look like?

1
docker image ls

ls (list images)

Let’s say we wanted to pull the image “tryhackme” (no quotations); what would our command look like?

1
docker pull tryhackme

Images can be downloaded using the docker pull command and providing the name of the image.

Let’s say we wanted to pull the image “tryhackme” with the tag “1337” (no quotations). What would our command look like?

1
docker pull tryhackme:1337

In Docker, a tag specifies a particular version of an image to pull, allowing you to choose between different builds (e.g., latest, 1337, alpine) of the same image repository.


[Task 3] Running Your First Container

What would our command look like if we wanted to run a container interactively? Note: Assume we are not specifying any image here.

1
docker run -it

To allow us to interact with the container directly, we need to use the -it switch.

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.

1
docker run -d

-d : This argument tells the container to start in “detached” mode. This means that the container will run in the background.

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.

1
docker run -p 80:80

-p : This argument tells Docker to bind a port on the host operating system to a port that is being exposed in the container.

How would we list all running containers?

1
docker ps

To list all containers, you can use docker ps.

Now, how would we list all containers (including stopped)?

1
docker ps -a

To list all containers (even stopped), you can use docker ps -a.


[Task 4] Intro to Dockerfiles

What instruction would we use to specify what base image the container should be using?

1
FROM

FROM : This instruction sets a build stage for the container as well as setting the base image (operating system). All Dockerfiles must start with this.

What instruction would we use to tell the container to run a command?

1
RUN

RUN : This instruction will execute commands in the container within a new layer.

What docker command would we use to build an image using a Dockerfile?

1
build

Once we have a Dockerfile, we can create an image using the docker build command.

Let’s say we want to name this image; what argument would we use?

1
-t

Whether or not you want to name the image yourself (we will use the -t (tag) argument).


[Task 5] Intro to Docker Compose

I want to use docker-compose to start up a series of containers. What argument allows me to do this?

1
up

up : This command will (re)create/build and start the containers specified in the compose file.

I want to use docker-compose to delete the series of containers. What argument allows me to do this?

1
down

down : This command will stop and delete the containers specified in the compose file.

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

1
docker-compose.yml

docker-compose.yml - One file to rule them all.


[Task 6] Intro to the Docker Socket

What does the term “IPC” stand for?

1
Interprocess Communication

Interprocess Communication is the definition of the mechaism that allows processes to communicate and share data between each other.

What technology can the Docker Server be equalled to?

1
API

In the context of Docker, the Docker Server is effectively just an API.


[Task 7] Practical

Connect to the machine. What is the name of the container that is currently running?

1
CloudIsland

Use the command docker ps.

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?

1
THM{WEBSERVER_CONTAINER}

Use the command docker run -p 80:80 webserver.

This post is licensed under CC BY 4.0 by the author.