Take an nginx Dockerfile as an example:
# This is my first nginx Dockerfile
# Version 1.0
# Base images
FROM ******/system/centos:7.5
# MAINTAINER Information of the maintainer
MAINTAINER ruyan000@qq.com
# ADD Obtain the file from the URL and place it in the current directory
ADD nginx-1.14.0.tar.gz.
# RUN Execute the following commands
RUN yum install -y pcre-devel wget net-tools gcc zlib zlib-devel make openssl-devel
RUN useradd -M -s /sbin/nologin nginx
RUN tar -zxvf nginx-1.14.0.tar.gz
RUN mkdir -p /usr/local/nginx
RUN cd nginx-1.14.0 &&./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module && make && make install
RUN ln -s /usr/local/nginx/sbin/* /usr/local/sbin/
# EXPOSE Map the port
EXPOSE 80
# CMD Run the following command
CMD ["nginx", "-g", "daemon off;"]
In the above Dockerfile:
- The
FROM
statement: indicates that the centos:7.5 image is used as the base.- The
MAINTAINER
statement: provides the information of the Dockerfile creator.- The
RUN
statement: indicates that a certain shell command is executed in the container.- The
ADD
statement: copies the file from the local machine into the container.- The
ENTRYPOINT
statement: the command to start the container.- The
CMD
statement: a SHELL instruction.- The
EXPOSE
statement: the container opens the specified port to communicate with the outside.
How to add a certain file or directory in a Git project to an image?