> For the complete documentation index, see [llms.txt](https://docs.monarchlinux.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.monarchlinux.com/basics/shell-aliases/docker.md).

# Docker

See [Shell aliases and functions](https://docs.monarchlinux.com/basics/shell-aliases.md) for command discovery and personal overrides.

These helpers require Docker daemon access. Some also need fzf or jq. They do not grant access themselves: use Monarch's authenticated Docker launcher or your configured Docker access workflow. Do not change socket permissions to bypass authentication. Docker access can confer root-equivalent host control.

## Select a running container

`dex` uses fzf to select a running container, then executes the command you provide. `dexr` does the same as root inside the container. Cancelling selection does not execute a command.

```bash
dex /bin/sh
dexr /bin/sh
```

The selected image must contain the requested executable. Extra arguments are passed as separate arguments, not evaluated as a shell command.

`din` inspects a selected running container through jq:

```bash
din '.[0].NetworkSettings'
```

## Run an image against the current directory

`dockit <image> [command…]` runs an interactive, temporary container. It mounts the current directory at `/monhost`, uses it as the working directory and also mounts host `/tmp` at `/tmp`.

Those mounts are writable. Container processes can change host files there; use trusted images and an appropriate working directory. The container is removed on exit, but changes to mounted host files remain.

## Stop containers

* `dps`: list running containers.
* `dstopall`: stop every running container.
* `dnorestart`: disable automatic restart for every running container.
* `dkillall`: disable automatic restart, then stop all running containers.

These operate globally, not just on the current project. Inspect running containers before using them.

## Cleanup requires care

Helpers named `dwipe-*` remove Docker resources. In particular, `dwipe-all` invokes a noninteractive system prune with image and volume cleanup enabled. Other helpers can target all listed containers, images, networks or volumes.

Do not run them as routine cleanup without inspecting their definitions and backing up data. Prefer explicit Docker commands for a selected resource when you need a narrower scope.
