docker-cli讀取Dockerfile,根據指令生成定製的docker鏡像。java
構建指令:用於構建image,其指定的操做不會在運行image的容器上執行;linux
設置指令:用於設置image的屬性,其指定的操做將在運行image的容器中執行。docker
1.構建指令apache
FROMubuntu
MAINTAINERtomcat
WORKDIRcookie
RUNoracle
ENVapp
ADDssh
COPY
VOLUME
2.設置指令
CMD
ENTRYPOINT
USER
EXPOSE
## Dockerfile的指令是忽略大小寫的,建議使用大寫,使用 # 做爲註釋,每一行只支持一條指令,每條指令能夠攜帶多個參數。
FROM ubuntu:13.10 MAINTAINER zing wang "zing.jian.wang@gmail.com" RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe"> /etc/apt/sources.list RUN apt-get update RUN apt-get -y install curl RUN cd /tmp && curl -L 'http://download.oracle.com/otn-pub/java/jdk/7u65-b17/jdk-7u65-linux-x64.tar.gz' -H 'Cookie: oraclelicense=accept-securebackup-cookie; gpw_e24=Dockerfile' | tar -xz RUN mkdir -p /usr/lib/jvm RUN mv /tmp/jdk1.7.0_65/ /usr/lib/jvm/java-7-oracle/ RUN update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-7-oracle/bin/java 300 RUN update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-7-oracle/bin/javac 300 ENV JAVA_HOME /usr/lib/jvm/java-7-oracle/ RUN cd /tmp && curl -L 'http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.8/bin/apache-tomcat-7.0.8.tar.gz' | tar -xz RUN mv /tmp/apache-tomcat-7.0.8/ /opt/tomcat7/ ENV CATALINA_HOME /opt/tomcat7 ENV PATH $PATH:$CATALINA_HOME/bin ADD tomcat7.sh /etc/init.d/tomcat7 RUN chmod 755 /etc/init.d/tomcat7 EXPOSE 8080 ENTRYPOINT service tomcat7 start && tail -f /opt/tomcat7/logs/catalina.out
From 47.xxx.xxx.xxx:10010/openjdk8-apline-ssh:v0.1 WORKDIR /app COPY app.jar /app/app.jar RUN chown -R 1000:1000 /app && chmod -R 750 /app && mkdir /app/config && chown -R 1000:1000 /app/config && chmod -R 750 /app/config EXPOSE 8050 ENTRYPOINT java -jar /app/app.jar USER 1000:1000
#在Dockerfile全部目錄下 docker build -t xxx:xxx:xxx:xxx:10000/demo:v0.1 .
參考: