# Docker

## CLI Commands

### Download Image

{% code overflow="wrap" %}

```bash
docker pull <image_name>:<tag>
```

{% endcode %}

### Exec into Container

{% code overflow="wrap" %}

```bash
docker exec -it <name> /bin/bash
```

{% endcode %}

* The `name` is what you used when launching the container
* `-it` launches an interactive shell (bash in this case)

### Kill a Running Container

{% code overflow="wrap" %}

```bash
docker rm <name> --force
```

{% endcode %}

* The `name` is what you used when launching the container

### List Local Images

{% code overflow="wrap" %}

```bash
docker image ls
```

{% endcode %}

### List Running Containers

{% code overflow="wrap" %}

```bash
docker ps -a
```

{% endcode %}

### Login to a Registry

{% code overflow="wrap" %}

```bash
docker login --username <username> --password-stdin <registry_name>
```

{% endcode %}

### Run Docker Image Locally

{% code overflow="wrap" %}

```bash
docker run --platform linux/amd64 -it --name <whatever> <image_name>
```

{% endcode %}

* `--platform linux/amd64`  (Optional) Makes the warning go away when executing x86 images on ARM


---

# Agent Instructions: 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:

```
GET https://www.techwithtyler.dev/kubernetes-and-containers/docker.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
