1. 程式人生 > 實用技巧 >docker中搭建Ubuntu:16.04+python3.6+django環境

docker中搭建Ubuntu:16.04+python3.6+django環境

用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 .建立映象