there's a bug in the latest 2.7 version of the container
docker pull python:2.7
docker run -it --rm python:2.7 bash -c 'apt-get update && apt-get install -y supervisor && supervisord 鈥攈elp'
...
...
Processing triggers for systemd (215-17+deb8u4) ...
bash: /usr/bin/supervisord: /usr/bin/python: bad interpreter: No such file or directory
I think this issue is related with https://github.com/docker-library/python/pull/131
This is also affecting us, supervisor from the debian packages stopped working.
This is also a problem for the lsb-release package:
$ docker run -it --rm python:3.5 /bin/bash
root@403420f42ad8:/# apt-get update
Get:1 http://security.debian.org jessie/updates InRelease [63.1 kB]
Ign http://httpredir.debian.org jessie InRelease
Get:2 http://security.debian.org jessie/updates/main amd64 Packages [373 kB]
Get:3 http://httpredir.debian.org jessie-updates InRelease [142 kB]
Get:4 http://httpredir.debian.org jessie Release.gpg [2373 B]
Get:5 http://httpredir.debian.org jessie-updates/main amd64 Packages [17.6 kB]
Get:6 http://httpredir.debian.org jessie Release [148 kB]
Get:7 http://httpredir.debian.org jessie/main amd64 Packages [9032 kB]
Fetched 9778 kB in 1min 42s (95.6 kB/s)
Reading package lists... Done
root@403420f42ad8:/#
root@403420f42ad8:/#
root@403420f42ad8:/# apt-get install -y lsb-release
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
lsb
The following NEW packages will be installed:
lsb-release
0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded.
Need to get 26.5 kB of archives.
After this operation, 99.3 kB of additional disk space will be used.
Get:1 http://httpredir.debian.org/debian/ jessie/main lsb-release all 4.1+Debian13+nmu1 [26.5 kB]
Fetched 26.5 kB in 1s (22.7 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package lsb-release.
(Reading database ... 21490 files and directories currently installed.)
Preparing to unpack .../lsb-release_4.1+Debian13+nmu1_all.deb ...
Unpacking lsb-release (4.1+Debian13+nmu1) ...
Setting up lsb-release (4.1+Debian13+nmu1) ...
root@403420f42ad8:/#
root@403420f42ad8:/#
root@403420f42ad8:/#
root@403420f42ad8:/# lsb_release
bash: /usr/bin/lsb_release: /usr/bin/python: bad interpreter: No such file or directory
I'm facing this when running node installer scripts from nodesource/distributions repo which use lsb_release to identify the O.S. version.
setup_6.x: /usr/bin/lsb_release: /usr/bin/python: bad interpreter: No such file or directory
I'm seeing the exact same issue as @pitervergara. I believe this was introduced in a819c92949e182901df10e52d41bc57c6ca73bd5 when this was replaced:
RUN apt-get purge -y python.*
I believe that command would have left /usr/bin/python in place, but when it effectively replaced with dpkg-divert --rename /usr/bin/py* that scooped up /usr/bin/python which used to be untouched.
I don't have any background on the reasoning behind that change so I don't feel confident suggesting what the "correct" behavior is.
Unrelated to the python issue, for @pitervergara's I suggest just replacing the call to the nodesource installation script with the Nodesource manual installation instructions instructions in your Dockerfile.
Thanks for the tip, @jalessio !
About node, I did exactly that to make my build run again.
I agree that the issue arrived with that change, because now the files are named "*.distrib", which seems to be the intention of that commit, but the lsb_release and perhaps some other utilities are expecting to find a python executable at /usr/bin/python.
root@b3742b74c10d:/# ls -l /usr/bin/py*
...
lrwxrwxrwx 1 root root 9 Mar 16 2015 /usr/bin/python.distrib -> python2.7
-rwxr-xr-x 1 root root 3785928 Mar 1 2015 /usr/bin/python2.7.distrib
lrwxrwxrwx 1 root root 9 Mar 16 2015 /usr/bin/python2.distrib -> python2.7
...
root@b3742b74c10d:/# head /usr/bin/lsb_release
#! /usr/bin/python -Es
# lsb_release command for Debian
# (C) 2005-10 Chris Lawrence <[email protected]>
...
One solution is probably just to symlink the Python that is built in this image from source to the location that things expect the Debian version to be:
RUN ln -s /usr/local/bin/python /usr/bin/python
Things like the Debian-packaged supervisor were working before because apt would just reinstall Python after it was purged as a dependency of the supervisor package. This effectively resulted in 2 Pythons being installed (3 Pythons if you include the Python in the lower layers that is purged).
@JayH5, at least for the lsb_release package, synlinking the python interpreter won't work because of the PYTHONPATH.
The python version at _/usr/bin/python_ is the 3.5 compiled into the image, and the debian original _/usr/bin/python_ is a 2.7, whith different lib folder.
To use symlink, we have to point it to the "diverted" one.
root@fb96f95a04d5:/# lsb_release -a
bash: /usr/bin/lsb_release: /usr/bin/python: bad interpreter: No such file or directory
root@fb96f95a04d5:/#
root@fb96f95a04d5:/#
root@fb96f95a04d5:/# ln -s /usr/local/bin/python /usr/bin/python
root@fb96f95a04d5:/#
root@fb96f95a04d5:/# lsb_release -a
Traceback (most recent call last):
File "/usr/bin/lsb_release", line 28, in <module>
import lsb_release
ImportError: No module named 'lsb_release'
root@fb96f95a04d5:/#
root@fb96f95a04d5:/#
root@fb96f95a04d5:/# unlink /usr/bin/python
root@fb96f95a04d5:/# ln -s /usr/bin/python2.7.distrib /usr/bin/python
root@fb96f95a04d5:/#
root@fb96f95a04d5:/# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.5 (jessie)
Release: 8.5
Codename: jessie
root@fb96f95a04d5:/#
Also, note that it must be the "/usr/bin/python2.7.distrib" because "/usr/bin/python.distrib" and "/usr/bin/python2.distrib" both are symlinks to a missing file (the original interpreter name, before dpkg-divert)
Supervisor issues for us also, running 2.7.12. Has there been any update on this?
To get around the issue you can use ADD pip install supervisor package. However, /supervisord.conf etc are missing so I just installed both pip first then apt-get versions of Supervisor and between them it fill in the gaps. This is not ideal nor recommended.
I had used home-brew to install 2.7 on Ubuntu and the new install was missing the sym links. I ran
brew link --overwrite python
Simply run this
sudo bash -c "test -e /usr/bin/python || (apt -qqy update && apt install -qy python-minimal)
Then run command "katoolin"
Most helpful comment
@JayH5, at least for the lsb_release package, synlinking the python interpreter won't work because of the PYTHONPATH.
The python version at _/usr/bin/python_ is the 3.5 compiled into the image, and the debian original _/usr/bin/python_ is a 2.7, whith different lib folder.
To use symlink, we have to point it to the "diverted" one.
Also, note that it must be the "/usr/bin/python2.7.distrib" because "/usr/bin/python.distrib" and "/usr/bin/python2.distrib" both are symlinks to a missing file (the original interpreter name, before dpkg-divert)