> For the complete documentation index, see [llms.txt](https://rejenthompson.gitbook.io/writeups/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rejenthompson.gitbook.io/writeups/try-hack-me-writeups/thm-intro-to-docker.md).

# THM : Intro to Docker

<figure><img src="/files/a8xfloDQaNOOpsd2GMi0" alt=""><figcaption></figcaption></figure>

This guide walks you through the "Intro to Docker" room on TryHackMe, covering Docker basics, useful commands, and practical tasks for container management and orchestration. Whether you're new to Docker or refreshing your skills, this overview will help you gain a solid foundation in containerization.

***

#### Task 1: Introduction

No specific answers are needed for this task. If you've completed the Linux Fundamentals module on TryHackMe, you're well-prepared for this room.

***

#### Task 2: Basic Docker Syntax

1. **Pull an Image**: To pull a Docker image from Docker Hub, use:

   ```bash
   docker pull <image_name>
   ```
2. **List All Images**: To list all Docker images on your system, use:

   ```bash
   docker image ls
   ```
3. **Example Command**: To pull a specific image:

   ```bash
   docker pull tryhackme
   ```

   To pull a specific tag of an image:

   ```bash
   docker pull tryhackme:1337
   ```

***

#### Task 3: Running Your First Container

1. **Run a Container Interactively**:

   ```bash
   docker run -it <image_name>
   ```
2. **Run in Detached Mode**:

   ```bash
   docker run -d <image_name>
   ```
3. **Bind a Web Server to Port 80**:

   ```bash
   docker run -p 80:80 <image_name>
   ```
4. **List Running Containers**:

   ```bash
   docker ps
   ```
5. **List All Containers (Including Stopped)**:

   ```bash
   docker ps -a
   ```

***

#### Task 4: Intro to Dockerfiles

1. **Specify Base Image**:

   ```dockerfile
   FROM <base_image>
   ```
2. **Run a Command**:

   ```dockerfile
   RUN <command>
   ```
3. **Build an Image from a Dockerfile**:

   ```bash
   docker build -t <image_name> .
   ```

***

#### Task 5: Intro to Docker Compose

1. **Start Services with Docker Compose**:

   ```bash
   docker-compose up
   ```
2. **Stop and Remove Services**:

   ```bash
   docker-compose down
   ```
3. **Docker Compose File**: The configuration file for Docker Compose is named `docker-compose.yml`.

***

#### Task 6: Docker Socket and IPC

1. **IPC (Interprocess Communication)**: Docker enables communication between processes in containers.
2. **Docker Server Comparison**: The Docker Server’s functionality can be compared to an API for managing and interacting with containers.

***

#### Task 7: Practical

1. **Identify Running Container**: Connect to the machine to find the container name, which is typically listed as "CloudIsland."
2. **Run a Web Server**:

   ```bash
   docker run -d -p 80:80 webserver
   ```

   After launching the web server, visit the provided URL to retrieve the flag.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://rejenthompson.gitbook.io/writeups/try-hack-me-writeups/thm-intro-to-docker.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
