New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
0.15.0 causes OSError: [Errno 8] Exec format error: in Docker for Windows #1482
Comments
Hi same issue here. Tested on
This is caused by the changes in |
Given the code above in a file called app.py, with cwd() being
With ['/home/user/.virtualenvs/test-ChRUEUMK/bin/python', 'app.py'] With ['/home/user/Projects/test/app.py'] Prepending |
@shinuza check if app.py is executable, if yes - set chmod 644 app.py. Or second way, add shebang on the top of app.py like #!/usr/bin/env python |
@shinuza there https://github.com/pallets/werkzeug/blob/0.15.x/src/werkzeug/_reloader.py#L90 lines 90-94 the "'/home/user/.virtualenvs/test-ChRUEUMK/bin/python'" was removed if app.py executable. |
@kamyanskiy I just figured this out reading the code but the error should be as cryptic as it is right now. |
Also, if I explicitly run |
@shinuza I don't think its a critical bug, in other words its a bit stricter now than before. So I shouldn't have executable app.py without shebang, it doesn't make sense. And second I shouldn't run executable with shebang like "python app.py". But I agree, probably that was unexpected for you as for me :) To workaround just add shebang to your app.py, I hope this will help. |
If you mark a script as executable, you should add a corresponding interpreter comment to the top. You can use a tool like pre-commit's If you don't intend for a script to be directly executable, and want to require |
As I said, I agree with the main logic here. I disagree with the way the error is dealt with as well as the fact that the error message is unintelligible unless you know the know the technical details or read the code. It should at least be documented in the changelog. |
We have no control over the error message, that comes from Linux. The fact that we changed how executable files are handled is listed in the changelog:
|
Making the file not executable works. The shebang line does not, for me. I get file not found errors, instead. That was the first thing I tried. With
I also think making a change that works only on one Linux distribution but breaks the rest doesn't seem ideal. Making the files not executable seems like the proper solution, but this still feels broken to me. |
@penner42 try #!/usr/bin/env python
probably you don't have symlink on python3 |
Same result. The python3 symlink is there, and just running FWIW, Docker does gives this warning when building. |
Use the FROM python:3.7-alpine
WORKDIR /app
ENV FLASK_ENV development
ENV FLASK_APP example
EXPOSE 5000
RUN ["pip", "install", "flask"]
CMD ["flask", "run", "-h", "0.0.0.0"]
|
Did the tutorial at https://docs.docker.com/compose/gettingstarted/ used to work on Windows 7?
|
Did the same tutorial and found the same issue. This fixed it for me. I added the following shebang to the top of my
Which then caused permission issues. I then added the following to my
|
This comment has been minimized.
This comment has been minimized.
Changes to Docker Compose tutorial proposed in docker/docs#8609. |
Fixed in Werkzeug 0.15.5. |
The new 0.15.0 does not run in Docker for Windows. Have not tried Docker on other platforms.
Minimal example with Flask.
app.py
Dockerfile
requirements.txt
Run
docker build -t flask_test .
and thendocker run flask_test
.Error in container:
Uncomment the first line in
requirements.txt
and it runs properly after rebuild.The text was updated successfully, but these errors were encountered: