In the docker Study Notes (1), we mentioned using the commit command to submit a new image. Next we will use the Dockerfile file to generate an image and use the Dockerfile for convenient transplantation. I. Several Common commands in Dockerfile: (1) FROM: FROMimage or FROMimage: tag (2) MAINTAINER
In the docker Study Notes (1), we mentioned using the commit command to submit a new image. Next we will use the Dockerfile file to generate an image and use the Dockerfile for convenient transplantation. 1. Several Common commands in Dockerfile: (1) FROM: FROM image or FROM image: tag (2) MAINTAINER
In the docker Study Notes (1), we mentioned using the commit command to submit a new image. Next we will use the Dockerfile file to generate an image and use the Dockerfile for convenient transplantation.
I. Several Common commands in Dockerfile:
(1) FROM
Format:
FROM
Or
FROM :
(2) MAINTAINER
Format:
MAINTAINER
Description: sets the creator of the generated image.
(3) RUN
Format:
Using shell
RUN
Or in the exec format.
RUN ["executable", "param1", "param2"]
Note: The RUN Command runs the command on a new layer on the current Image and submits the result. These results will be used in the next step of Dockerfile.
(4) CMD
Format:
CMD ["executable","param1","param2"]
Or
CMD ["param1","param2"]
Or
CMD command param1 param2
Note: The CMD command executes the service when the container is started, for example, a command, a service, or a script.
Note: A Dockerfile can only have one CMD command. If there are multiple command lines, only the last one is valid.
(5) ADD
Format:
ADD
....
Note:
If you want to ADD a local file, the local file must be in the docker build , The specified Directory, such as ADD files/root/hadoop_files: lchown/var/lib/docker/aufs/mnt .......................... not a directory and other error messages)
If you want to ADD a remote file, the remote file must be in the docker build , The specified Directory, such as: ADD https://archive.apache.org/dist/hadoop/common/hadoop-1.0.4/hadoop-1.0.4-bin.tar.gz/root/
(6) VOLUME
Format:
VOLUME ["/data"]
Note: you can mount local folders or other container folders to the container.
Ii. Example
The following Dockerfile creates an image based on ubuntu: precise.
Run the docker build-t ubuntu: base. Command.
#Authro:wgc#Data:2014-10-24#Introduction:Build basic developmentFrom ubuntu:precise# Set correct source listRUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.listRUN echo "deb http://archive.ubuntu.com/ubuntu precise-updates main universe" >> /etc/apt/sources.list# Install a few other useful packages plus Open Jdk 7RUN apt-get update && apt-get upgrade -y && apt-get install -y openjdk-7-jdk wget vim sudo openssh-server # Add hadoop_filesADD files /root/hadoop_files/# Set JAVA_HOMEENV JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64RUN echo export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 >> /root/.bashrc# Download hadoopADD https://archive.apache.org/dist/hadoop/common/hadoop-1.0.4/hadoop-1.0.4-bin.tar.gz /root/
Refer:
(1)docs.doc ker.com/reference/builder/
(2) http://blog.csdn.net/wsscy2004/article/details/25878223
(3) tonyunc.com/tag/blog/