executed.
If you specify the running command when starting the container, it will overwriteCMDThe specified command.Expose
Format:EXPOSE .
Inform the docker server of the port number exposed by the container for the interconnected system.Env
Format:ENV . Specify an environment variable.RUNCommand used and maintained during container running.
For example
ENV PG_MAJOR 9.3ENV PG_VERSION 9.3.4RUN curl -SL http://example.com/postgres-$PG_VERSION.tar.xz |
Building a Java Web environment with Dockerfile is mainly divided into 2 steps, the first step is to install the JDK in the mirror and configure the environment variables, and the second step is to install Tomcat.
Let's put up a complete dockerfile.
From ubuntu:14.04
Maintainer * * * ***@******.com "
RUN apt-get update
ADD jdk-8u77-linux-x64.tar.gz/usr/ Local/java
://example.com/postgres-$PG _version.tar.xz | tar-xjc/usr /src/postgress
... ENV path/usr/local/postgres-$PG _major/bin: $PATH1 2 3 4
7, ADDFormat is ADD.
This command copies the specified to the container. This can be a relative path to the directory where Dockerfile is located, a URL, or a tar file (automatically unzipped to a directory). The
8, COPY
The format is COPY.
Copies the local host's (the relat
Tags: dockerfile create with MongoDBMongoDB is a scalable, high-performance open source document (document-oriented) database. It is developed in C + +, supports complex data types and powerful query language, and provides most of the functions of relational databases. MongoDB has been widely used in various fields because of its high performance, easy to deploy and easy to use.① Download FileDownload the MongoDB mirroring project from the GitHub Dock
Maintenance person information for new image
RUN command
Executes the command on the mirror on which it is based and submits it to the new mirror
Expose port number
Specifies the port number that is opened when the new image is loaded into Docker
ENV environment variable Variable value
Setting the value of an environment variable will be used by the following run
ADD sour
1. Java DockerfileCreate the project directory Java, upload the required Java version of the compressed package in the directory, and create the Dockerfile file, the project structure is as follows:Java-dockerfile-jdk-8u111-linux-x64.gzDockerfile content:# java# Version 1.8.0_111# source_imagefrom centos# maintainer_infomaintainer bluemooder [email protected]add jdk-8u111-linux-x64.gz/usr/local/# envenv jav
Dockerfile
From base Mirror
Maintainer maintain this information
What command runs run, plus run in front of the command
Add to add some files, copy files, will automatically extract
Workdir the current working directory
VOLUME Directory Mount
Expose Open ports
The run process has to be running
Combat: Building Nginx
wget http://xiazai.jb51.net/201611/yuanma/nginx-1.9.3 (jb51.net). rar
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/p
As a docker project, dockerfile files are built, tagged, and published. If you can include these operations on the Dockerfile file in Maven lifecycle management, it will greatly simplify the build and release process of the Docker project.
Dockerfile maven is a maven plugin from Spotify that also includes a MAVEN extension that assists with
Start by creating a CentOS container #docker create CENTOS:CENOS6
Deletes a container. A005304E4E74 (Mirror ID)-F parameter is forced to delete, sometimes dependencies will not remove Docker rmi-f a005304e4e74
View current container: Docker images
If you have the following information: Create the image successfully CentOS CENTOS6 a005304e4e74 weeks ago 203.1 MB
Enter the container:
#docker run-t-I. CENTOS:CENTOS6
Create a directory (if successful, display the following terminal, 061a24a8acca
Using Dockerfile to build an nginx image
How Docker constructs images: Commit, Dockerfile
1. Use commit to build the image:
Commit is a mirror built on the basis of the original image, using this method to build the image: Save some configuration information and the modified information in the image. Corresponds to a snapshot of a mirror.
2. Use Dockerfile to bu
1, in the host to create folders tomcat7.0_jdk1.7, download tomcat7.0 and JDK put into this directory[email protected] ~/tomcat7.0_jdk1.7 $ lsDockerfile apache-tomcat-7.0.68 JDK run.sh2, Write Dockerfile[email protected] ~/tomcat7.0_jdk1.7 $ cat DockerfileFrom sshd:centos6.5Maintainer created from [email protected]ENV Catalina_home/tomcatENV JAVA_HOME/JDKADD Apache-tomcat-7.0.68/tomcatADD JDK/JDKADD run.sh/
This is a creation in
Article, where the information may have evolved or changed.
Dockerfile Best Practices
Why
As a very good lightweight PaaS solution, Docker has been supported by the mainstream cloud service platform, with the Docker Registry Hub providing high-quality Docker Image and Fig for Containers management, attracting global developers to Migrate your services to Docker Containers to improve development and deployment efficiencies. As a
Tags: mysqld service mirrorCreate a build directory structure# MKDIR-PV docker/mysql# CD docker/mysql/Two write dockerfile files#vimdockerfile #此处 sshd:latest Image created for the previous article # this dockerfile" dookerpool"'s dockerfile file, just made some optimizations and changes during testing Fromsshd:latestmaintainermykernel (www.mykernel.cn) # Install
After the Docker 17.05 release, a new Dockerfile multi-stage build was added. The so-called multi-stage build, in effect, allows multiple from directives to appear in a dockerfile. What is the point of doing this?
Why does the old version of Docker not support multiple from directives
Prior to the 17.05 release of Docker, only one from instruction was allowed in the Doc
Dockerfile
files those things
(
one
)
The Dockerfile is used to build the image , and there are several instructions in the file :FromMaintainerRUNEXPOSEAfter these four commands, let's talk about their role.There are also a few common directives :CmdEnterypointADDCOPYVOLUMEWorkdirEnvUSERThese commands, even if I say it, can't remem
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.