docker 打包ubuntu和python映象並提交到倉庫
基於ubuntu建立名為docker_ser的容器
更新映象: apt-get update
安裝對應工具包: apt-get install -y vim
更換ubuntu映象為阿里雲
開啟配置檔案:
cp /etc/apt/sources.list /etc/apt/sources.list.bak
rm /etc/apt/sources.list
vim /etc/apt/sources.list
回車
按 i 進入插入模式
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
效果圖:
退出;
更新映象
apt-get update
apt-get install -y wget
apt-get install -y openssh-server
apt-get install -y net-tools # ifconfig
apt-get install -y iputils-ping # ping
apt-get install -y gcc
apt-get install -y make
安裝python環境
apt-get install -y python3
apt-get install -y python3-pip
apt-get install -y python2.7
apt-get install -y python-pip
測試:
python3
pip3 list
python2
pip2 list
另:如果需要在python3中安裝django
pip3 install (-i https://pypi.douban.com/simple)django
ubuntu更換pip源
1、 mkdir ~/.p
2、 cd ~/.p
3、 vi pip.conf
4、寫入配置
[global]
timeout = 6000
index-url = https://pypi.douban.com/simple
trusted-host = pypi.douban.com
5、儲存退出
打包映象
docker commit -a '提交人' -m '介紹' 容器名(id) 映象名稱
例:docker commit -a 'zhansan' -m 'installed python2 and python3' docker-sev docker_python