用vim 新建一个Dockerfile和sources.list文件,在里面添加如下内容。
#sources.list
deb http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse
#Dockerfile
FROM ubuntu:16.04
MAINTAINER NSS/CZH
COPY ./sources.list /etc/apt/sources.list
RUN apt-get update \
&& apt-get install gcc -y\
&& apt-get install g++ -y\
&& apt-get install gdb -y\
&& apt-get install python-software-properties -y\
&& apt-get install software-properties-common -y\
&& add-apt-repository ppa:deadsnakes/ppa -y\
&& apt-get update\
&& apt-get install python3.6 -y\
&& rm /usr/bin/python\
&& ln -s /usr/bin/python3.6 /usr/bin/python\
&& rm /usr/bin/python3\
&& ln -s /usr/bin/python3.6 /usr/bin/python3\
&& apt-get install python3-pip -y\
&& pip3 install pip -U\
&& rm /usr/bin/pip3 \
&& ln -s -f /usr/local/bin/pip3 /usr/bin/pip3\
&& ln -s -f /usr/local/bin/pip3 /usr/bin/pip\
&& pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple\
&& pip install django\
&& rm -rf /var/lib/apt/lists/*
使用docker build -t ubuntu:py36 .
创建镜像