Question: I'm trying to let you use values from other keys in a configuration dictionary, but it doesn't work, (sorry if it's a stupid question im new to python coming from c++). I am converting it to a json object since it returns a string and you can only format strings

The code:

```py
import getopt, sys, json

def main():
    dicto = {"key":"yes", "cool":"{key}"}
    str_dicto = json.dumps(dicto)
    print(dicto)
    print(str_dicto.format(key = dicto["key"]))

if __name__ == "__main__":
    main()

```

The error:

```
C:\Users\MyUserName>python test.py

C:\Users\MyUserName>python test.py
{'key': 'yes', 'cool': '{key}'}
Traceback (most recent call last):
  File "C:\Users\MyUserName\test.py", line 10, in <module>
    main()
  File "C:\Users\MyUserName\test.py", line 7, in main
    print(str_dicto.format(key = dicto["key"]))
KeyError: '"key"'

```

Answer: 
See the [doc](https://docs.docker.com/engine/reference/commandline/run/), the switch for environment variable is `-e`:

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

```

and in [dockerfile](https://docs.docker.com/engine/reference/builder/), you can use

```
ENV FOO=/bar

```

If I understand your statement correctly, your paths are mounted in the container in the same path as the host. The only problem is your Python script, which expects the paths to be provided by the environment variable. This will not exist unless you pass on them from your host system to your container system.

Once you verified your mounted volume with `-v` is there correctly, you can try with

```
docker run -v %POPPLER%:%POPPLER% -v %TESSERACT%:%TESSERACT% --env POPPLER=%POPPLER% --env TESSERACT=%TESSERACT% ocr

```

or, if you always run this, you can consider to put them in your dockerfile to save some keystroke.
Any executable you call must be built into the image. Containers can't usually call executables on the host or in other containers. In the specific example you show, a Linux container can't run a Windows executable, even if you do use a bind mount to inject it into the container.

The "slim" [`python` images](https://hub.docker.com/_/python/) are built on Debian GNU/Linux, and you need to use its APT tool to install these executable dependencies in your Dockerfile. (<https://www.debian.org/distrib/packages> has a search box to help you find the right package name; Ubuntu Linux also uses Debian packages.)

```sh
FROM python:3.7-slim
RUN apt-get update \
 && DEBIAN_FRONTEND=noninteractive \
    apt-get install -y \
      popper-utils \
      tesseract-ocr-all
COPY requirements.txt .
...

```

I'd suggest putting reasonable defaults in your code if these environment variables aren't set. The `apt-get install` command will put them in the system path inside the image.

```python
popplerPath = os.environ.get('POPPLER', 'poppler')
tesseractPath = os.environ.get('TESSERACT', 'tesseract')

```

If you really need them as environment variables you could use the Dockerfile `ENV` directive

```sh
ENV POPPLER=poppler TESSERACT=tesseract

```

Environment variables from the host don't automatically get passed through to the container; you need a Dockerfile `ENV` or `docker run -e` option. Also remember that the container has an isolated filesystem (and Windows-syntax paths don't make sense in Linux containers) so these environment variables would need to be container paths, the second half of your proposed `docker run -v` option.