-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathcustom-image-dockerfile
41 lines (41 loc) · 1.68 KB
/
custom-image-dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
##Base image
FROM centos
##Author name
LABEL author="AUTHOR_NAME"
##Description for this custom image
LABEL description="This is a custom AMI"
##Packages to install in the container
RUN yum update -y && yum install httpd -y && yum install git -y && yum install java -y
## Port number to expose for the container
EXPOSE 80
## Environment variable in the dockerfile
ENV dir /var/www/html
## Copy index file from host machine to container machine.
COPY ./index.html $dir
## Download a file from internet and copy to container machine.
ADD http://mirrors.jenkins.io/war-stable/latest/jenkins.war $dir
## start the apache server
CMD ["/usr/sbin/httpd","-D","FOREGROUND"]
#ENTRYPOINT
## Create a folder
RUN mkdir /myvol
## add contents to the greeting file
RUN echo "This is a persistent voume" > /myvol/greeting
## Create a persistent volume that is available even after the container is destroyed
VOLUME /myvol
## Set the working directory
WORKDIR $dir
## Create a dynamic variabe whose value will be passed outside the dockerfile using "--build-arg"
ARG file
## Passing the value from ARG
RUN touch $file
## Passing the value from ARG
RUN mkdir $file.html
## Providing the onbuild instructions that will get executed when using this image as a base image.
ONBUILD RUN touch index.html
## Providing the onbuild instructions that will get executed when using this image as a base image.
ONBUILD RUN mkdir index_folder
## Providing the onbuild instructions that will get executed when using this image as a base image.
ONBUILD RUN yum install mysql -y
## Create a healthcheck for the application running inside the container.
HEALTHCHECK CMD curl -f http://YOUR_MACHINE_IP_ADDRESS:8080/index.html || exit 1