use docker to setup building environment for a project

来源:互联网 发布:2002数据库怎么使用 编辑:程序博客网 时间:2024/05/16 04:40
setup building environment for visage

1. get ubuntu14.04 docker VM image
docker pull ubuntu:14.04

2. run docker VM
docker run -t -i --privileged --cap-add=ALL -v /home/ping/workspace/visage:/workspace ubuntu:14.04 /bin/bash
project source codes are located in /home/ping/workspace/visage

3. install packages to VM
apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf make gcc g++ vim cmake device-tree-compiler bc pkg-config
in docker VM, install packages

4. do build in docker VM
make u-boot
make kernel
make rootfs
./flash.sh visage mmcblk0p1
build successfully

5. exit and commit docker VM
exit
docker ps -a
docker commit -m "visage build" 29281fc26380 joe/ubuntu:14.04
docker images

6. run next time
docker run -t -i --privileged --cap-add=ALL -v /home/ping/workspace/visage:/workspace joe/ubuntu:14.04 /bin/bash

7. logs
ping@116-15:~/workspace/visage$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
joe/ubuntu          14.04               3c78f8a5d16d        16 minutes ago      209.7 MB
ubuntu              14.04               b549a9959a66        14 hours ago        188 MB
ping/centos         centos5             dace46dc23f9        26 hours ago        1.908 GB
ubuntu              latest              a1e4ed2ac65b        2 days ago          188 MB
centos              centos5             505999341f87        5 days ago          284.7 MB
centos              centos6             fc73b108c5ae        5 days ago          228.9 MB
ping@116-15:~/workspace/visage$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                           PORTS               NAMES
29281fc26380        joe/ubuntu:14.04    "/bin/bash"         15 minutes ago      Exited (0) 18 seconds ago                            stupefied_easley
0ec275a7ed09        ubuntu:14.04        "/bin/bash"         About an hour ago   Exited (130) About an hour ago                       desperate_payne
566fa4d482df        ubuntu:14.04        "/bin/bash"         About an hour ago   Exited (0) 17 minutes ago                            mad_jepsen
905c2007d797        centos:centos6      "/bin/bash"         26 hours ago        Exited (0) 26 hours ago                              elated_bardeen
f05cc9181247        ade90d0f477d        "/bin/bash"         26 hours ago        Exited (0) 26 hours ago                              cranky_easley
e16a6652cc4c        ade90d0f477d        "/bin/bash"         26 hours ago        Exited (0) 26 hours ago                              big_newton
fba42f4d933a        eb9c039170d9        "/bin/bash"         27 hours ago        Exited (0) 27 hours ago                              tiny_elion
018ddd23a445        fb00c20ef1d9        "/bin/zsh"          27 hours ago        Exited (0) 27 hours ago                              dreamy_meitner
7b9a948487a9        75d8db5f310f        "/bin/bash"         27 hours ago        Exited (0) 27 hours ago                              fervent_jang
05ae3a4bb230        75d8db5f310f        "/bin/zsh"          27 hours ago        Created                                              big_snyder
5d6c75111c52        75d8db5f310f        "/bin/bash"         27 hours ago        Exited (0) 27 hours ago                              sad_pasteur
254380bb1fa7        077dae49a759        "/bin/bash"         28 hours ago        Exited (0) 28 hours ago                              nostalgic_hugle
3bdf0b2e6eec        077dae49a759        "/bin/bash"         28 hours ago        Exited (0) 28 hours ago                              loving_ardinghelli
ea7da154d834        ubuntu:latest       "/bin/bash"         28 hours ago        Exited (0) 28 hours ago                              evil_cray
7fd2fab0af3d        077dae49a759        "/bin/bash"         29 hours ago        Exited (1) 28 hours ago                              boring_fermi
9461952c3fca        077dae49a759        "/bin/bash"         29 hours ago        Exited (0) 29 hours ago                              determined_bhabha
fa5f07942016        077dae49a759        "/bin/bash"         29 hours ago        Exited (0) 29 hours ago                              pedantic_engelbart
29c986a956d7        077dae49a759        "/bash/bin"         29 hours ago        Created                                              sharp_darwin
9e29d043d9dd        077dae49a759        "/bash/bin"         29 hours ago        Created                                              kickass_noether
d2f11c04978c        077dae49a759        "/bash/bin"         29 hours ago        Created                                              amazing_heisenberg
c29d2ebe0861        centos:centos5      "/bin/bash"         4 days ago          Exited (0) 45 hours ago                              pensive_lumiere
ping@116-15:~/workspace/visage$ docker commit -m "visage build" 29281fc26380 joe/ubuntu:14.04

sha256:e46e9112da3c4ac3bb1f4250c73f31f35671cd8fe68be3d28968b754840e4727
ping@116-15:~/workspace/visage$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
joe/ubuntu          14.04               e46e9112da3c        13 seconds ago      527.5 MB
ubuntu              14.04               b549a9959a66        14 hours ago        188 MB
ping/centos         centos5             dace46dc23f9        26 hours ago        1.908 GB
ubuntu              latest              a1e4ed2ac65b        2 days ago          188 MB
centos              centos5             505999341f87        5 days ago          284.7 MB
centos              centos6             fc73b108c5ae        5 days ago          228.9 MB
0 0