> For the complete documentation index, see [llms.txt](https://www.techwithtyler.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.techwithtyler.dev/kubernetes-and-containers/docker.md).

# 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
