docker(ubuntu)最小镜像中什么都没有,安装Python时需要安装各种组件
首先准备docker环境:
# docker pull ubuntu # docker run --name python -idt ubuntu bash # docker exec -it python /bin/bash
然后安装组件:
0、首先更新源
# apt-get update
1、安装wget
# apt-get install wget
2、安装ping,ifconfig
# apt-get install inetutils-ping # apt-get install net-tools
3、安装gcc
# apt-get install gcc
4、安装各种依赖包
# apt-get install zlib* bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel tcl-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-dev
5、安装libressl
# wget https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.9.0.tar.gz # tar -xzf libressl-2.9.0.tar.gz # cd libressl-2.9.0.tar.gz # ./configure # make # make install
最后安装Python
# wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz # tar -xzvf Python-3.7.2.tgz # cd Python-3.7.2 # ./configure --enable-optimizations # make # make install
安装心得:
安装较新版本会出现各种各样的问题,各个环境的支持情况都不明确,所有建议安装已经在源中验证过的版本,够用就行:
# sudo apt-get install python3 # sudo apt-get install python3-pip