1

I'm opening a docker container and running an inline bash script. The bash script runs python code but I'm not always sure what that code will be.

Because it's arbitrary code, I'd like to enable a kill switch to close this container within 30 seconds. Is there a way to do that within this code that I'm running:

docker run my/image sh -c '$(curl -ss -o python_file.py https://www.example.com); \
    python python_file.py'

Basically before running the python file, I'd like to start a timer. And if that timer hits 30 seconds, I run docker kill this specific container.

I've tried the following but it's not working.

timeout 30 docker run my/image sh -c '$(curl -ss -o python_file.py https://www.example.com); \
    python python_file.py'
bumpkin
  • 3,321
  • 4
  • 25
  • 32

0 Answers0