# Docker Containers

Safety is available in a Docker container, if you'd like to scan across Python versions or use Safety without having to install it or Python locally.

To get started, you can run the `pyupio/safety-v2-beta` image. Any arguments provided will be transparently passed through to Safety:

```shell
Bash
$ sudo docker run --rm -ti pyupio/safety-v2-beta --version
safety, version 2.0b5
```

Scanning from a requirements file works as expected, you just need to make sure to volume mount your project so that Safety can access it inside the container:

```shell
Bash
$ sudo docker run --rm -ti -v /path/to/my/project:/target pyupio/safety-v2-beta check -r /target/requirements.txt --key <YOUR-API-KEY>
```

You can also scan from stdin; this allows you to generate the list of dependencies outside the Docker container, while Safety runs within it. This is most useful when you're running an older version of Python for your application (eg, Python 2.7):

```shell
Bash
$ python -m pip list --format=freeze | sudo docker run -i --rm pyupio/safety-v2-beta check --stdin --key <YOUR-API-KEY>
```

Lastly, you can pass in an environment for Safety to scan. This can be a bit tricky, as you'll need to pass in the `site-packages` folder, and set the PYTHONPATH to ensure Safety scans it correctly. The following example is for a local virtualenv:

```shell
Bash
$ sudo docker run --rm -ti -v /path/to/my/project:/target -e PYTHONPATH=/target/.venv/lib/python3.10/site-packages pyupio/safety-v2-beta check --key <YOUR-API-KEY>
```


---

# 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://docs.safetycli.com/safety-2/safety-cli-2-scanner/docker-containers.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.
