set and using docker - HybridOS/Document GitHub Wiki

Using docker build Android

<1>Docker installation on ubuntu 14.04.03

sudo apt-get install docker.io docker

<2> pull ubuntu14.04 docker image

sudo docker images

sudo docker pull ubuntu:14.04

sudo docker images


<3>Stop docker:

service docker stop. Verify no docker process is running ps faux

Make a backup tar -zcC /var/lib docker > /bak/var_lib_docker-backup-$(date +%s).tar.gz

Move the /var/lib/docker directory to your new partition:

mv /var/lib/docker /home/zhongtian/workdir/lib/docker/ 

ln -s /mnt/pd0/docker /var/lib/docker

<4>edit docker default run dir config file

mkdir -p  /home/zhongtian/workdir/lib/docker
sudo vim /etc/default/docker

-DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"

+DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4 -g /home/zhongtian/workdir/lib/docker"

<4> Start docker back up

service docker start

<5> create a file name 'Dockerfile' and add some cmd line

-----------------------------------------------------------
FROM ubuntu:14.04



ADD sources.list /etc/apt/sources.list



ENV DEBIAN_FRONTEND noninteractive



RUN apt update ; apt install -y git-core gnupg flex bison gperf build-essential \

zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev \

x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils \

xsltproc unzip squashfs-tools python-mako gettext syslinux



WORKDIR /var/aosp

-----------------------------------------------------------------------

copy a 'source.list' file in the same dir with 'Dockerfile'

<6> build a docker image named 'aosp-build'

sudo docker build -t aosp-build .

if successed, a docker image named 'aosp-build' was produced,then you can do as below

<7>create a docker container named "aosp-l"

sudo docker run -v /home/zhongtian/workdir/android-x86/docker:/var/aosp/source -i -t --name aosp-l aosp-build bash

if succesed, you will go into a docker env, ctrl+d or exit can quit docker;

next time you only click as below start a contianer

sudo docker start -ai aosp-l

<8>Commit Changes to Docker

To create a new image from changes to a container, it’s a simple as running just one command.

Before we do so, however, let’s change the container!

finally it’s time to commit our changes to a named image.

This command converts the container 9c09acd48a25 to an image with the name fedora-base-with-git:

docker commit 9c09acd48a25 fedora-base-with-git

Docker uses the “commits are cheap” concept in its design.

You’re encouraged to commit frequently and at any point in an image’s history, much like version control.

Local Mirror

1、在A机压缩后,复制到B机器并解压缩tar -cf – /opt/dir1 | ssh 192.168.0.116 “cd /opt; tar -xf -” 2、在A机压缩,并将压缩文件复制到B机tar -cf – /opt/dir1 | ssh 192.168.0.116 “cd /opt; cat – > dir1.tar” 3、将A机d压缩文件,复制到B机并解压缩zcat dir.tar | ssh 192.168.0.116 “cd /opt; tar -xf -”