1. 下載範例 project
2. 檢視 Dockerfile$ git clone -b v1 https://github.com/docker-training/node-bulletin-board $ cd node-bulletin-board/bulletin-board-app
3. build docker imageFROM node:6.11.5 WORKDIR /usr/src/app COPY package.json . RUN npm install COPY . . CMD [ "npm", "start" ]
Dockerfile 描述了如何為 container 組裝 private filesystem, 也包含了 metadata 描述如何根據 docker image 執行 container.
4. 根據 build 好的 docker image, 啟動 container$ docker image build -t bulletinboard:1.0 .
5. 觀察 application 執行的結果$ docker container run --publish 8000:8080 --detach --name bb bulletinboard:1.0
6. 刪除 container
7. 刪除 docker image$ docker container rm --force bb
$ docker image rm bulletinboard:1.0
參考文章
Containerizing an application