Docker run Could not find any locustfile! Ensure file ends in '.py'
See original GitHub issueDescribe the bug
I followed the instructions on https://docs.locust.io/en/stable/running-locust-docker.html to try to run the docker image
docker run -p 8089:8089 -v $PWD:/mnt/locust locustio/locust -f /mnt/locust/locustfile.py
but received this error " Could not find any locustfile! Ensure file ends in ‘.py’".
Here is my locustfile.py in $PWD:
import time
from locust import HttpUser, task, between
class QuickstartUser(HttpUser):
wait_time = between(1, 2)
@task
def index_page(self):
self.client.get("/")
This file works fine with locust running on my local machine (Ubuntu WSL of Windows 10), i.e. not using the container. I confirm the environment variable $PWD is present and pointing to my present working directory where my locustfile.py resides.
Expected behavior
The Docker run above should start Locust server and make its UI accessible on http://localhost:8089.
Actual behavior
$ docker run -p 8089:8089 -v $PWD:/mnt/locust locustio/locust -f /mnt/locust/locusttest1.py Could not find any locustfile! Ensure file ends in '.py' and see --help for available options.
Surprisingly the above (default to latest tag) shows version 1.1. So I also tried v 1.3.1 but got the same error.
$ docker run -p 8089:8089 -v $PWD:/mnt/locust locustio/locust:1.3.1 -f /mnt/locust/locusttest1.py Could not find any locustfile! Ensure file ends in '.py' and see --help for available options.
Steps to reproduce
-
copy my locustfile.py contents into a new file named locustfile.py in your working directory
-
run
$ docker run -p 8089:8089 -v $PWD:/mnt/locust locustio/locust -f /mnt/locust/locusttest1.py
Environment
- OS: Ubuntu 16.04 WSL of Windows 10
- Python version: irrelevant because I am running the docker image
- Locust version: 1.1 as shown by
docker run -p 8089:8089 -v $PWD:/mnt/locust locustio/locust --version
- Locust command line that you ran: see above
docker run ...
- Locust file contents (anonymized if necessary): see above
Issue Analytics
- State:
- Created 3 years ago
- Comments:12
Top GitHub Comments
Done. Added the How to tip in https://github.com/locustio/locust/wiki/FAQ.
will do