$ echo deb http://get.docker.io/ubuntu docker main \ | sudo tee /etc/apt/sources.list.d/docker.list $ sudo apt-key adv --keyserver keyserver.ubuntu.com \ --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 $ sudo apt-get update $ sudo apt-get install -y lxc-docker
$ sudo docker search gitbook NAME DESCRIPTION STARS OFFICIAL AUTOMATED tobegit3hub/gitbook-server 2 [OK]
$ sudo docker pull tobegit3hub/gitbook-server
$ sudo docker images | grep gitbook tobegit3hub/gitbook-server latest d171079650c8 $ sudo docker run -i -t \ tobegit3hub/gitbook-server /bin/bash
$ apt-get install git $ apt-get install fonts-arphic-gbsn00lp
Markdown
Pandoc
各种格式自由转换
GitBook
GitBook 本身是一个 Git 仓库
重要组件
README.md: 书籍简介
静态 HTML 页面
gitbook build ./ --output=./_book/
gitbook pdf
gitbook serve ./
Starting server …
Serving book on http://localhost:4000
http://localhost:4000
SyntaxError:…/book.json:Unexpected token o
GitBook 调试
export DEBUG=true
GitBook 插件
Google Analytics
$ git clone \ https://github.com/tobegit3hub/understand_linux_process.git
$ cd understand_linux_process $ gitbook build $ gitbook pdf
Docker 侧
$ ifconfig eth0 | grep "inet addr" inet addr:172.17.0.31 ... $ gitbook serve ./ Starting server ... Serving book on http://localhost:4000
主机侧
$ readlink -f book.pdf /gitbook/understand_linux_process/book.pdf
docker cp CONTAINER_ID:PATH HOSTPATH
$ sudo docker ps -a CONTAINER ID IMAGE COMMAND cf5925e tobegit3hub/gitbook-server "/bin/bash" $ sudo docker cp \ cf5925e:/gitbook/understand_linux_process/book.pdf
两个步骤
$ fullid=`sudo docker inspect -f '{{.Id}}' cf5925e` $ gitbook=/var/lib/docker/aufs/mnt/$fullid/gitbook/ $ ls $gitbook understand_linux_process $ cp book.pdf $gitbook/book-from-host.pdf
$ fullid=`sudo docker inspect -f '{{.Id}}' cf5925e` $ gitbook=/var/lib/docker/aufs/mnt/$fullid/gitbook/ $ ls $gitbook understand_linux_process $ cp book.pdf $gitbook/book-from-host.pdf
$ sudo docker commit cf5925e tinylab/gitbook $ sudo docker images | grep tinylab/gitbook tinylab/gitbook latest 2106b9f7f675
$ sudo docker save tinylab/gitbook > gitbook.tar
$ sudo docker load < gitbook.tar
删除/杀掉容器
docker rm [-f] contaier_id
docker kill contaier_id
停止容器
docker stop container_id
启动容器
docker start container_id
删除镜像
docker rmi image_id
# Dockerfile FROM ubuntu:14.04 MAINTAINER Falcon wuzhangjin@gmail.com RUN sed -i -e "s/archive.ubuntu.com/mirrors.163.com/g" \ /etc/apt/sources.list RUN apt-get -y update RUN apt-get install -y nodejs npm git && \ npm install gitbook -g RUN apt-get install -y calibre RUN apt-get install -y fonts-arphic-gbsn00lp RUN mkdir /gitbook WORKDIR /gitbook EXPOSE 4000 CMD ["gitbook", "serve", "/gitbook"]
# Dockerfile FROM ubuntu:14.04 MAINTAINER Falcon wuzhangjin@gmail.com RUN sed -i -e "s/archive.ubuntu.com/mirrors.163.com/g" \ /etc/apt/sources.list RUN apt-get -y update RUN apt-get install -y curl git && cd / && \ git clone https://github.com/creationix/nvm.git nvm && \ echo ". /nvm/nvm.sh" > ~/.bashrc && . ~/.bashrc && \ nvm install 0.12.2 && nvm use 0.12.2 && \ npm install gitbook -g RUN apt-get install -y calibre RUN apt-get install -y fonts-arphic-gbsn00lp RUN mkdir /gitbook WORKDIR /gitbook EXPOSE 4000 CMD ["gitbook", "serve", "/gitbook"]
$ sudo docker build -t tinylab/gitbook ./
-c, –cpu-shares=0 CPU shares (relative weight)
–cpuset-cpus= CPUs in which to allow execution (0-3, 0,1)
-m, –memory= Memory limit
sudo groupadd docker
sudo gpasswd -a ${USER} docker
sudo service docker restart
/var/run/docker.sock
所属 docker 组具有 setuid 权限$ sudo ls -l /var/run/docker.sock srw-rw—- 1 root docker 0 May 1 21:35 /var/run/docker.sock