Docker下搭建android编译环境

Docker-从入门到实践

  1. 从镜像站下载一个Ubuntu16.04镜像
    sudo docker pull ubuntu 16.04

  2. 检测镜像是否下载到本地
    sudo docker images

  3. 运行容器
    sudo docker run -it --name test_xx ubuntu:16.04 /bin/bash

  4. 进入容器界面
    root@b81e3e43f524:/data#

  5. 容器换源

    • 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
  1. 调整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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值