Docker 工作原理及容器化简易指南
包含应用程序及其所有依赖的文件系统快照。
容器启动时的运行命令。
umermansoor:dockerprj$ touch Dockerfile
# Use Alpine Linux rootfs tarball to base our image on
FROM alpine:3.9
# Set the working directory to be '/home'
WORKDIR '/home'
# Setup our application on container's file system
RUN wget http://www.cs.cmu.edu/afs/cs/academic/class/15213-s00/www/class28/tiny.c \
&& apk add build-base \
&& gcc tiny.c -o tiny \
&& echo 'Hello World' >> index.html
# Start the web server. This is container's entry point
CMD ["./tiny", "8082"]
# Expose port 8082
EXPOSE 8082
umermansoor:dockerprj$ docker build -t codeahoydocker .
Successfully tagged codeahoydocker:latest
文件系统快照(Alpine Linux 和 我们安装的 Web 服务)
启动命令(./tiny 8092)
umermansoor:dockerprj$ docker run -p 8082:8082 codeahoydocker:latest
https://docs.docker.com/install/
https://docs.docker.com/get-started/#images-and-containers