-
从镜像站下载一个Ubuntu16.04镜像
sudo docker pull ubuntu 16.04 -
检测镜像是否下载到本地
sudo docker images -
运行容器
sudo docker run -it --name test_xx ubuntu:16.04 /bin/bash -
进入容器界面
root@b81e3e43f524:/data# -
容器换源
- rm /etc/apt/sources.list
- cat>/etc/apt/souces.list<<EOF
- 执行了上面的语句后,复制下面的信息,以EOF三个字符做为最后一行进行结束
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb 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 main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
- cat /etc/apt/sources.list输出整个信息。查看修改是否正确
6.在容器中安装工具
- apt update
- apt install build-essential (install gcc)
- apt install vim
- apt install iputils-ping (install ping)
- apt-get install python3.6
- 调整python系统默认使用版本
- update-alternatives --install /usr/bin/python python /usr/bin/python2.7.1 0
- update-alternatives --install /usr/bin/python python /usr/bin/python3.6 1
- update-alternatives --list python
- update-alternatives --config python (选择对应的版本做为默认版本)
10.生成镜像
不要退出当前容器,在新建一个终端窗口,以下操作均在新终端下完成。
sudo docker commit -m “description” -a “author” <容器id> repository:tag
- “description”:描述信息。
- “author”:作者名。
- <容器id>:可以在就终端那里看到,形如root@2ce6712ef339:/#。可以看到<容器id>是2ce6712ef339。
- reposiory:镜像仓库名,任取即可。
- tag:镜像标签名,任取即可。
- eg: docker commit -m “ubuntu 16.04 with aliyun and build-essential” -a “build” 2ce6712ef339 ubuntu-build/ubuntu:16.04
11.查看镜像是否生成
sudo docker images
12.利用repo下载android源码
repo init -u ssh://git@url -b master -m manifest.xml --repo-url=https://gerrit-googlesource.proxy.ustclug.org/git-repo