系統(tǒng)環(huán)境
- CentOS 7
- Docker 18.02.0-ce
編寫Dockerfile文件
mkdir gitbook
cd gitbook
vi Dockerfile
以下是Dockerfile的內(nèi)容
# Use an official Node.js runtime as a parent image
FROM node:8.11.1
# Set npm registry to China Taobao and install Gitbook
RUN npm config set registry https://registry.npm.taobao.org && \
npm install gitbook-cli -g && \
gitbook -V && \
mkdir /gitbook
# Make port 4000 available to the world outside this container
EXPOSE 4000
CMD ["sh", "-c", "gitbook install /gitbook; gitbook serve /gitbook"]
生成鏡像
# 最后是鏡像名和版本扛或,可以根據(jù)實際情況更改
sudo docker build -t gitbook:3.2.3 .
運(yùn)行鏡像
# 啟動可能會較慢
docker run -d -p 4000:4000 -v /home/test/docker_practice:/gitbook gitbook:3.2.3
推送鏡像至私有倉庫
# 打標(biāo)簽
docker tag gitbook:3.2.3 harbor.test.com/library/gitbook:3.2.3
# 登錄私有倉庫
docker login harbor.test.com
# 推送至私有倉庫
docker push harbor.test.com/library/gitbook:3.2.3