上一篇文章提到我build出了edx(birch)的docker版。

此前appsembler(国外提供edx服务的一家公司)在docker hub上发布过edx-lite和edx-full,不过一直停留在aspen版本。而birch版本修复了不少重大bug,并加入了分组之类的实用特性,我几个月前写邮件问他们是否有发布birch版本的打算,他们回复说:

We do already have some birch images that we use for our clients, but those are currently only for internal use as they contain our API keys and other private stuff. I think we plan on releasing the birch images publicly at some point, but I can’t tell you when exactly as we have more urgent work to do at the moment.

回信的末尾说发布出来后会通知我,我也等不及了,就自己去build了。

在此记录build的过程

#环境 * Ubuntu14.04 * docker1.7

#安装最新版docker wget -qO- https://get.docker.com/ | sh

#开始安装

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
:::text
#base image
sudo docker pull phusion/baseimage
git clone https://github.com/appsembler/configuration.git -b docker_release ~/configuration
sudo docker run -i -t -p :80 -p :18010 -p :18020 -d -v ~/configuration:/configuration phusion/baseimage /sbin/my_init --enable-insecure-key
sudo docker ps #获取<container_id>

#进入到容器里开始安装,此后的过程和在ubuntu12.04上部署相似
sudo docker exec -it <container_id> bash

#处理elasticsearch相关的两个问题
1.vim playbooks/roles/elasticsearch/tasks/main.yml
     force=no
+    validate_certs=no
   register: elasticsearch_reinstall
   
2.vim playbooks/roles/elasticsearch/tasks/main.yml
+- name: Disable dynamic scripting
+  lineinfile: "dest=/etc/elasticsearch/elasticsearch.yml line='script.disable_dynamic: true'"
+  sudo: True
+  when: not ELASTICSEARCH_CLUSTERED
 
 - name: create directories
   file: >

#安装依赖
apt-get update && apt-get install -y python-dev python-setuptools python-apt gcc && easy_install pip
cd /configuration && pip install -r requirements.txt

#安装edx-lite,里边只跑着cms,lms和forum
cd playbooks && ansible-playbook -vv -c local -i "127.0.0.1," docker_lite.yml  #中途失败后可以用 --start-at-task="xx"继续

#成功后,记得commit,移除"/sbin/my_init",
docker commit -a "wwj718<wuwenjie718@gmail.com>" -run '{"Cmd":["--enable-insecure-key"], "PortSpecs":["22","80","5000", "18010", "18020"]}' <container_id> wwj718/edx-lite:birch

#push到docker hub
docker push wwj718/edx-lite:birch

#导出(export)
sudo docker export <container_id> > edx-lite_birch_export.tar

#也可以这样导出(save)
sudo docker save wwj718/edx-lite:birch > edx-lite_birch_save.tar

关于docker中export和save的区别,stackoverflow上的这个回答说的很好:

The exported image will not have any layer or history information saved, so it will be smaller and you will not be able to rollback