在我的 Kubuntu 18.04 中,我安装了 docker-ce 并运行 LAMP 实例时遇到 python 找不到的错误:
$ docker-compose up -d --build
Building web
Step 1/3 : FROM php:7.2-apache
---> 35e5c60e1f7d
Step 2/3 : RUN apt-get update && apt-get install -y libfreetype6-dev libwebp-dev libjpeg62-turbo-dev libpng-dev nano git-core curl build-essential openssl libssl-dev libgmp-dev libldap2-dev netcat sqlite3 libsqlite3-dev && git clone https://github.com/nodejs/node.git && cd node && ./configure && make && sudo make install docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-webp-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && docker-php-ext-install gd pdo pdo_mysql pdo_sqlite zip gmp bcmath pcntl ldap sysvmsg exif && a2enmod rewrite
---> Running in 65d838fde10d
Get:1 http://security-cdn.debian.org/debian-security buster/updates InRelease [39.1 kB]
Get:2 http://cdn-fastly.deb.debian.org/debian buster InRelease [118 kB]
Get:3 http://cdn-fastly.deb.debian.org/debian buster-updates InRelease [49.3 kB]
Get:4 http://security-cdn.debian.org/debian-security buster/updates/main amd64 Packages [82.1 kB]
Get:5 http://cdn-fastly.deb.debian.org/debian buster/main amd64 Packages [7897 kB]
Get:6 http://cdn-fastly.deb.debian.org/debian buster-updates/main amd64 Packages [884 B]
Fetched 8187 kB in 2s (3674 kB/s)
Reading package lists...
...
Reading package lists...
Get:42 http://cdn-fastly.deb.debian.org/debian buster/main amd64 xauth amd64 1:1.0.10-1 [40.3 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 21.1 MB in 3s (6954 kB/s)
Selecting previously unselected package less.
...
Setting up libfreetype6-dev:amd64 (2.9.1-3) ...
Processing triggers for libc-bin (2.28-10) ...
Processing triggers for mime-support (3.62) ...
Cloning into 'node'...
Checking out files: 100% (32035/32035), done.
./configure: 4: exec: python: not found
ERROR: Service 'web' failed to build: The command '/bin/sh -c apt-get update && apt-get install -y libfreetype6-dev libwebp-dev libjpeg62-turbo-dev libpng-dev nano git-core curl build-essential openssl libssl-dev libgmp-dev libldap2-dev netcat sqlite3 libsqlite3-dev && git clone https://github.com/nodejs/node.git && cd node && ./configure && make && sudo make install docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-webp-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && docker-php-ext-install gd pdo pdo_mysql pdo_sqlite zip gmp bcmath pcntl ldap sysvmsg exif && a2enmod rewrite' returned a non-zero code: 127
我注意到了消息:
since apt-utils is not installed
但是我已经安装了这个软件包:
$ dpkg --get-selections | grep apt-utils
apt-utils install
并在安装后重新启动了我的操作系统
# docker info
Client:
Debug Mode: false
Server:
Containers: 3
Running: 0
Paused: 0
Stopped: 3
Images: 1
Server Version: 19.03.2
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 894b81a4b802e4eb2a91d1ce216b8817763c29fb
runc version: 425e105d5a03fabd737a126ad93d62a9eeede87f
init version: fec3683
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.15.0-20-generic
Operating System: Ubuntu 18.04.3 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 7.711GiB
Name: serge-at-hoe
ID: 4IWA:LRTR:4UJS:FEDE:PCOJ:ZFFB:RLXR:LRPT:7QBI:XGLY:VVIV:TNJQ
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No swap limit support
My web/Dockerfile.yml :
FROM php:7.2-apache
RUN apt-get update &&
apt-get install -y
libfreetype6-dev
libwebp-dev
libjpeg62-turbo-dev
libpng-dev
nano
git-core
curl
build-essential
openssl
libssl-dev
libgmp-dev
libldap2-dev
netcat
sqlite3
libsqlite3-dev
&& git clone https://github.com/nodejs/node.git
&& cd node
&& ./configure
&& make
&& sudo make install
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-webp-dir=/usr/include/ --with-jpeg-dir=/usr/include/ &&
docker-php-ext-install gd pdo pdo_mysql pdo_sqlite zip gmp bcmath pcntl ldap sysvmsg exif
&& a2enmod rewrite
COPY virtualhost.conf/etc/apache2/sites-enabled/000-default.conf
我在我的操作系统中发现:
$ python3 --version
Python 3.6.8
$ python --version
Python 2.7.15+
$ python2 --version
Python 2.7.15+
$ dpkg --get-selections | grep python
libpython-stdlib:amd64 install
libpython2.7:amd64 install
libpython2.7-minimal:amd64 install
libpython2.7-stdlib:amd64 install
libpython3-stdlib:amd64 install
libpython3.6:amd64 install
libpython3.6-minimal:amd64 install
libpython3.6-stdlib:amd64 install
python install
python-appindicator install
python-apt-common install
python-asn1crypto install
python-backports.ssl-match-hostname install
python-cached-property install
python-cairo:amd64 install
python-certifi install
python-cffi-backend install
python-chardet install
python-cryptography install
python-dbus install
python-docker install
python-dockerpty install
python-dockerpycreds install
python-docopt install
python-enchant install
python-enum34 install
python-funcsigs install
python-functools32 install
python-gi install
python-glade2 install
python-gobject install
python-gobject-2 install
python-gtk2 install
python-gtksourceview2 install
python-idna install
python-ipaddress install
python-jsonschema install
python-minimal install
python-mock install
python-mysql.connector install
python-openssl install
python-paramiko install
python-pbr install
python-pexpect install
python-pkg-resources install
python-ptyprocess install
python-pyasn1 install
python-pyodbc install
python-pysqlite2 install
python-qt4-dbus install
python-requests install
python-six install
python-talloc install
python-texttable install
python-urllib3 install
python-websocket install
python-yaml install
python2.7 install
python2.7-minimal install
python3 install
python3-apport install
python3-apt install
python3-aptdaemon install
python3-aptdaemon.gtk3widgets install
python3-asn1crypto install
python3-blinker install
python3-bs4 install
python3-cairo:amd64 install
python3-certifi install
python3-cffi-backend install
python3-chardet install
python3-commandnotfound install
python3-cryptography install
python3-cups install
python3-cupshelpers install
python3-dbus install
python3-dbus.mainloop.pyqt5 install
python3-debconf install
python3-debian install
python3-defer install
python3-distro-info install
python3-distupgrade install
python3-feedparser install
python3-gdbm:amd64 install
python3-gi install
python3-gi-cairo install
python3-html5lib install
python3-httplib2 install
python3-idna install
python3-jwt install
python3-lxml:amd64 install
python3-macaroonbakery install
python3-mako install
python3-markupsafe install
python3-minimal install
python3-nacl install
python3-oauthlib install
python3-olefile install
python3-pexpect install
python3-pil:amd64 install
python3-pkg-resources install
python3-problem-report install
python3-protobuf install
python3-ptyprocess install
python3-pymacaroons install
python3-pyqt5 install
python3-pyxattr install
python3-renderpm:amd64 install
python3-reportlab install
python3-reportlab-accel:amd64 install
python3-requests install
python3-requests-unixsocket install
python3-rfc3339 install
python3-sip install
python3-six install
python3-software-properties install
python3-systemd install
python3-tz install
python3-uno install
python3-update-manager install
python3-urllib3 install
python3-webencodings install
python3-xapian install
python3-xdg install
python3-xkit install
python3-yaml install
python3.6 install
python3.6-minimal install
可能是 docker 运行无效的 python 以及如何修复它吗?
$ lsb_release -d; uname -r; uname -i
Description: Ubuntu 18.04.3 LTS
4.15.0-20-generic
x86_64
$ docker -v
Docker version 19.03.2, build 6a30dfc
看起来容器中没有 Python。 尝试按如下方式修改
RUN apt-get update &&
apt-get install -y
python
在进行配置之前,它需要将python安装在容器中。