<commit_before>[Security Section](_security/README.md)

[Wiki - old one](https://github.com/andrzejsydor/docker/wiki)

# Creating Containers:

## Run a command in a new container:

`docker container run [OPTIONS] IMAGE [COMMAND] [ARG...]`

### Flags:

[https://docs.docker.com/engine/reference/commandline/container_run/](https://docs.docker.com/engine/reference/commandline/container_run/)

| cmd                  |                                                    |
| -------------------- | -------------------------------------------------- |
| `--help`             |                                                    |
| `--rm`               | Automatically remove the container when it exits   |
| `--detach` , -d      | Run container in background and print container ID |
| `--interactive` , -i | Keep STDIN open even if not attached               |
| `--tty` , -t         | Allocate a pseudo-TTY                              |
| `--publish` , -p     | Publish a container’s port(s) to the host          |
| `--publish-all` , -P | Publish all exposed ports to random ports          |
| `--volume` , -v      | Bind mount a volume                                |
| `--name`             | Assign a name to the container                     |
| `--mount`            | Attach a filesystem mount to the container         |
| `--network`          | Connect a container to a network                   |
| `--restart`          | Restart policy to apply when a container exits     |

Example:

`docker container run --rm -dit -name myCont alpine`



# Container Commands

## docker container

Manage containers

```none
docker container COMMAND
```

https://docs.docker.com/engine/reference/commandline/container/

| cmd       |                                              |
| --------- | -------------------------------------------- |
| `ls`      | List containers                              |
| `inspect` | Display detailed information                 |
| `top`     | display the running processes of a container |
| `restart` | restart one or more containers               |

Example:

`docker ls -a`
<commit_msg>container commands<commit_after>[Security Section](_security/README.md)

[Wiki - old one](https://github.com/andrzejsydor/docker/wiki)

# Creating Containers:

## Run a command in a new container:

`docker container run [OPTIONS] IMAGE [COMMAND] [ARG...]`

### Flags:

[https://docs.docker.com/engine/reference/commandline/container_run/](https://docs.docker.com/engine/reference/commandline/container_run/)

| cmd                  |                                                    |
| -------------------- | -------------------------------------------------- |
| `--help`             |                                                    |
| `--rm`               | Automatically remove the container when it exits   |
| `--detach` , -d      | Run container in background and print container ID |
| `--interactive` , -i | Keep STDIN open even if not attached               |
| `--tty` , -t         | Allocate a pseudo-TTY                              |
| `--publish` , -p     | Publish a container’s port(s) to the host          |
| `--publish-all` , -P | Publish all exposed ports to random ports          |
| `--volume` , -v      | Bind mount a volume                                |
| `--name`             | Assign a name to the container                     |
| `--mount`            | Attach a filesystem mount to the container         |
| `--network`          | Connect a container to a network                   |
| `--restart`          | Restart policy to apply when a container exits     |



## Environment variables

Use the `-e`, `--env`, and `--env-file` flags to set simple (non-array) environment variables in the container you’re running, or overwrite variables that are defined in the Dockerfile of the image you’re running.

https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file#set-environment-variables--e---env---env-file

## Example:

```
docker container run --rm -dit -name myCont alpine
```

```
docker run -e MYVAR1 --env MYVAR2=foo --env-file ./env.list
```

# Container Commands

## docker container

Manage containers

```none
docker container COMMAND
```

https://docs.docker.com/engine/reference/commandline/container/

| cmd       |                                              |
| --------- | -------------------------------------------- |
| `ls`      | List containers                              |
| `inspect` | Display detailed information                 |
| `top`     | display the running processes of a container |
| `restart` | restart one or more containers               |

Example:

`docker ls -a`

{'fraction_non_alphanumeric': 0.16564156945917285, 'fraction_numerical': 0.0004241781548250265, 'mean_word_length': 1.417221937467965, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 9, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6214800', 'n_tokens_mistral': 1234, 'n_tokens_neox': 1173, 'n_words': 360}