

This is how to build an image from Dockerfile. From the Top, First One is a Virtual host conf file, Second on is the sample html page for our website, The Third is our Dockerfile. rw-r-r- 1 aksarav wheel 861 Apr 9 05: 14 Dockerfile rw-r-r- 1 aksarav wheel 150 Apr 9 05: 14 index.html rw-r-r- 1 aksarav wheel 447 Apr 9 04: 56 nf

They have to be similar aksarav $ ls -rlt Let us cross-validate how the work directory of mine ( /apps/docker/MyTestApache) and yours look. If you are following along, you must have done everything perfect. # the Default command and the Command to start the app in our containerĬMD The final Directory Structure of our working directory # Say that our application is exposing a Port # Enable this website using a2ensite - command RUN a2ensite default-website RUN chown root:root /etc/apache2/sites-available/nf # Run one more command to change the ownership of the file we copied # Copy the file from the Current Host Directory to the ContainerĪDD nf /etc/apache2/sites-available/ĪDD index.html /var/www/html/devopsjunction # Run the command to Create a DocumentRoot RUN mkdir -p /var/www/html/devopsjunction
Docker run image status 一直是 up 4 minutes install#
# Run the command to install apache as a prerequisite RUN apt-get update & apt-get install -y apache2 # Define the Createor and Maintainer of this image MAINTAINER Sarav AK Good to have you here Ĭreate a Dockerfile with the following content on the same directory # Define the base image on top of which we are going to customize Now for our website, we need a welcome page, So you write one or use the following file and save in the name index.html on the same directory DevOpsJunction - Home Page Welcome to Devops Junciton. ErrorLog $/devopsjunction-access.log combinedĬreate a sample index.html file for our website ServerAlias ServerAdmin DocumentRoot /var/www/html/devopsjunctionĪllowOverride All Allow from all Require all granted you can update the values like ServerName and alias as per your requirement.

This is a minimal version of a virtual host file for apache. In my case the directory name is /apps/docker/MyTestApacheĬreate a file named nf and paste the following content. In your host server where the Docker CLI and Docker is installed,Ĭreate a new directory (or) choose an existing directory and perform the following steps. We will see how to create a Dockerfile image to create an Apache httpd Docker Container and Docker image. Since Apache is most widely used web server, Let us go with that. Let us make some plan on what image we are going to create. There are more instructions and elements you can use in the Dockerfile but these are basics and enough for us to create the image The Requirement/ The Plan the Container would run as long as the Default Command is running.ĪDD or COPY The files you want to copy into the container from your host.

Every Container must have a Default Command. For example if you are building Apache HTTP server image you can EXPOSE port 80ĬMD The Default Command of the container which gets created using this image. RUN – Commands to Run to make the image( the future container) in the way you wantĮXPOSE Do you want your image or application in the image to expose any port to the external world or at least to the host. you can either use a minimal OS image like CentOS, Alpine or you can create your own from the scratch by mentioning SCRATCH as a value to this. MAINTAINER – Who Crate and manage this container imageįROM – What is the base image, we are going to use to host our container. These are a list of information that we must put in the Dockerfile to create an image. What information should the Docker file have? you need to create a file named Dockerfile and specify some information in it. To know more about what is container refer this link How to Create a Docker Image?Ĭreating a Docker image is an easy job. The Running instances of the image are called as a container. a template using which you can create N number of containers The Image is a file more like a manifest, where you define what are the packages and software and configurations should be available when you create a container from the image. Image Credits to SwapnIl Dwivedi – UnSplash Image vs Container
