question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Docker run Could not find any locustfile! Ensure file ends in '.py'

See original GitHub issue

Describe 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:closed
  • Created 3 years ago
  • Comments:12

github_iconTop GitHub Comments

1reaction
jackhu008commented, Oct 24, 2020

Done. Added the How to tip in https://github.com/locustio/locust/wiki/FAQ.

1reaction
jackhu008commented, Oct 24, 2020

will do

Read more comments on GitHub >

github_iconTop Results From Across the Web

Docker Locust locustfile.py not found - Stack Overflow
But every time I try to start the container it fails with this error: Could not find any locustfile! Ensure file ends in...
Read more >
Running Locust with Docker — Locust 1.5.2 documentation
The official Docker image is currently found at locustio/locust. The docker image can be used like this (assuming that the locustfile.py exists in...
Read more >
Quick Tutorial on Locust
A locust file is just a normal Python module, it can import code from other files or packages. class MyUser(HttpUser):. Here we define...
Read more >
Locust + Python Examples: Variables + Assertions - BlazeMeter
In this post, we will show you how to start your first test using Locust and Python. Plus, get a step-by-step overview of...
Read more >
Using Docker and Locust to Load Test Sitecore
First, we need to get an image from Docker Hub with Locust installed. ... what TaskSets will be run against what server, and;...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found