linux mint下docker的安装步骤参照linux mint 19 安装docker
images
images
文件夹中创建文件dockerfile
或Dockerfile
(不需要后缀名),文件内容如下:FROM centos:7.6.1810
MAINTAINER username # 指定作者信息
RUN set -ex # 预安装所需组件
&& yum install -y wget tar libffi-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make initscripts && wget https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz && tar -zxvf Python-3.5.0.tgz && cd Python-3.5.0 && ./configure prefix=/usr/local/python3 && make && make install \dock
&& make clean && rm -rf /Python-3.5.0* && yum install -y epel-release && yum install -y python-pip
# 设置默认为python3
RUN set -ex # 备份旧版本python
&& mv /usr/bin/python /usr/bin/python27 && mv /usr/bin/pip /usr/bin/pip-python2.7 # 配置默认为python3
&& ln -s /usr/local/python3/bin/python3.5 /usr/bin/python && ln -s /usr/local/python3/bin/pip3 /usr/bin/pip
# 修复因修改python版本导致yum失效问题
RUN set -ex && sed -i "s#/usr/bin/python#/usr/bin/python2.7#" /usr/bin/yum && sed -i "s#/usr/bin/python#/usr/bin/python2.7#" /usr/libexec/urlgrabber-ext-down && yum install -y deltarpm
# 基础环境配置
RUN set -ex # 修改系统时区为东八区
&& rm -rf /etc/localtime && ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && yum install -y vim # 安装定时任务组件
&& yum -y install cronie
# 支持中文
RUN yum install kde-l10n-Chinese -y
RUN localedef -c -f UTF-8 -i zh_CN zh_CN.utf8
# 更新pip版本
RUN pip install --upgrade pip
ENV LC_ALL zh_CN.UTF-8
images
路径下执行命令docker build -t centos-with-python .
,注意后面的.
不能去掉。root@ThinkPad-X280:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos-with-python latest e96f7cfd1865 5 days ago 1.09GB
python 3 a2aeea3dfc32 12 days ago 932MB
ubuntu 16.04 5f2bf26e3524 3 weeks ago 123MB
ubuntu latest 775349758637 3 weeks ago 64.2MB
centos 7.6.1810 f1cb7c7d58b7 8 months ago 202MB
python 2.7.15 afc94ac1e19b 9 months ago 925MB
制作镜像过程中需要下载一些依赖,如果下载速度过慢可以考虑更换docker的源,在lnux mint
的操作步骤具体如下:
root
权限进入/etc/docker
;daemon.json
为如下内容:# 配置多个国内docker源
{
"registry-mirrors":["https://registry.docker-cn.com", "http://hub-mirror.c.163.com","https://pee6w651.mirror.aliyuncs.com"]
}
docker
,service docker restart
pip
安装第三方包时如果速度过慢,可用通过-i
参数指定源,例如:sudo pip3 install pandas -i https://pypi.tuna.tsinghua.edu.cn/simpl
制作整合centos7和python3的docker基础镜像
原文:https://www.cnblogs.com/crazysquirrel/p/11943802.html