What is the proper shebang to use in a python script to be used in a Dockerfile against the official python:3 docker image?

Viewed 1119

I'm writing a python3 script that is used in a Dockerfile. It is based on the official python:3 docker hub image. I've found that I get mixed results depending on what #! line I use in the script. The generally accepted #!/usr/bin/env python3 actually doesn't work. If I used the /usr/sbin/python3 like is the default on my system, it can't find some imported dependencies that I've done a pip3 install on right above. It seems that /usr/local/bin/python3 is the first python3 in the path inside the container. I'd like the script to run comfortably both inside and outside the container. For now I'm just calling the script with python3 in the Dockerfile and skipping the whole mess.

How do I setup the SheBang for best compatibility?

1 Answers

you need to use this shebang simply:

#!/usr/bin/env python
Related