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

# Docker Cheatsheet

## Running containers

#### Run container:

```bash
docker run
```

#### Run container in daemon mode:

```bash
docker run -d
```

#### Run container in daemon mode and set name:

```bash
docker run -d --name <name_of_container>
```

## Process

#### Show docker processes:

```bash
docker ps
```

## Images

#### Search of Images:

```bash
docker search <image_name>
```

#### Pull images from repo:

```bash
docker pull <image_name>
```

#### Show local images:

```bash
docker images
```

#### Remove docker images:

```bash
docker rmi <image_name>
```

#### Force remove docker images:

```bash
docker rmi -f <image_name>
```

## Build

#### Build docker container from docker file:

```bash
docker build -t <docker_file>
```

#### Build container but do not start the container:

```bash
docker start <docker_file>
```

## Container interaction

#### Basic command for interaction:

```bash
docker exec
```

#### Connect to interactive shell for a container

```bash
docker -exec -i -t <container_name>

docker -exec -it <container_name>
```

## Network

#### Display docker networks:

```bash
docker network
```

#### Create docker network:

```bash
docker network create <network_name>
```

#### Remove docker network

```bash
docker network rm <network_name>
```

## System

#### Remove all stopped containers, dangling images and unused networks (basically cleanup)

```bash
docker system prune
```

## Secrets

#### Create secrets that can be passed to docker:

```bash
docker secret create <secret_name> <file_name>
```

## Quick Remove

#### Remove all containers from server with one line:

```bash
docker service rm $(docker service ls -q)
```

## Resources

* [Official Docker documentation for all commands](https://docs.docker.com/engine/reference/run/)


---

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

```
GET https://docs.arkannis.net/containerization/docker/docker-cheatsheet.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.
