[Python] Running a script from /opt/ is failing with Docker mounts

Discussão em 'Python' iniciado por Stack, Maio 16, 2025.

  1. Stack

    Stack Membro Participativo

    I have a Python script that creates docker run commands and executes them. This runs just fine from my /home/myuser directory, but if I move it to /opt/myuser (having to sudo run everything there), all of a sudden my docker run command can't find the mounted data. Specifically, my docker run string is

    docker run --gpus all --privileged -v /home/myuser/data/input:/input/ -v /home/myuser/data/output:/output/ -v /home/myuser/data/key:/key mydocker process /input/filename -k /key/mykey.key -o /output/


    And the Docker error output says:

    "error": "a given key file \"/key/mykey.key\" does not exist"


    Any idea why moving this script to /opt/ all of a sudden fails when it's producing the same exact command that successfully completes when in my /home/ directory?

    I'm executing this from the Python script with:

    subprocess.call(docker_run_string, shell=True, stderr=log)


    May the subprocess.call() be the culprit?

    Continue reading...

Compartilhe esta Página