{"id":5227,"date":"2020-07-21T16:32:16","date_gmt":"2020-07-21T11:02:16","guid":{"rendered":"https:\/\/www.skynats.com\/?p=5227"},"modified":"2021-09-21T16:44:00","modified_gmt":"2021-09-21T11:14:00","slug":"how-to-create-apache-docker-image","status":"publish","type":"post","link":"https:\/\/www.skynats.com\/blog\/how-to-create-apache-docker-image\/","title":{"rendered":"How to Create Apache Docker Image"},"content":{"rendered":"\n<p><a href=\"https:\/\/www.apache.org\/\" target=\"_blank\" aria-label=\"undefined (opens in a new tab)\" rel=\"noreferrer noopener\">Apache<\/a> is an opensource web server that is commonly used for webpage deployments. Apache does support almost all operating systems worldwide. <a href=\"https:\/\/www.docker.com\/\" target=\"_blank\" aria-label=\"undefined (opens in a new tab)\" rel=\"noreferrer noopener\">Docker<\/a> is an opensource virtualization tool in which users can create, run, and deploy applications or software in packages called containers. The containers can communicate with each other through proper channels<\/p>\n\n\n\n<p>This blog will show the steps to create an Apache Docker image and deploy it. If you face any issues or got stuck with the process, kindly contact our <a aria-label=\"undefined (opens in a new tab)\" href=\"https:\/\/www.skynats.com\/contact-us\/\" target=\"_blank\" rel=\"noreferrer noopener\">experienced team<\/a> to resolve it.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Run and Deploy Apache Docker Images in Centos 7<\/strong><\/h4>\n\n\n\n<p><strong><span class=\"has-inline-color has-vivid-cyan-blue-color\">Install Docker on Centos 7<\/span><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yum install docker docker-distribution\nsystemctl start docker docker-distribution<\/code><\/pre>\n\n\n\n<p><strong><span class=\"has-inline-color has-vivid-cyan-blue-color\">Create Dockerfile for apache and open it<\/span><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir -p dockerapache\ncd dockerapache\/\nvim Dockerfile<\/code><\/pre>\n\n\n\n<p><strong><span class=\"has-inline-color has-vivid-cyan-blue-color\">Add the below content to the Docker File and Save the File<\/span><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>###########\nFROM centos:centos7\nRUN yum install httpd -y\nRUN mkdir -p \/var\/www\/html\nWORKDIR \/var\/www\/html\nRUN chown -R apache:apache \/var\/www\/html\/\nCOPY $PWD\/index.html \/var\/www\/html\/\nCOPY $PWD\/httpd.conf  \/etc\/httpd\/conf.d\/httpd.conf\nEXPOSE 80\nCMD &#91;\"\/usr\/sbin\/httpd\",\"-D\",\"FOREGROUND\"]\n###########<\/code><\/pre>\n\n\n\n<p>Whereas:<br><em>FROM &#8211;&gt; Create a layer from the alpine:latest image<br>RUN &#8211;&gt; It is used to execute the command within the image<br>MAINTAINER &#8211;&gt; Information about who is maintaining the Dockerfile<br>WORKDIR &#8211;&gt; It is the working directory of the docker image<br>ENV &#8211;&gt; To set environment variable inside the docker image<br>COPY &#8211;&gt; It is used to copy the files from the host (on which we create the Dockerfile) to the docker image.<br>ADD &#8211;&gt; It is same as the COPY command but there is two difference from COPY command;<br>1. ADD instruction can copy and extract tar files from the docker host( Dockerfile creating host) to the docker image.<br>2. ADD instruction can download files via HTTP and copy it into the docker image.<br>&nbsp;&nbsp;CMD &#8211;&gt; Command specifies the command line command to be executed when a docker container is started up based on a docker image created from the Dockerfile.<\/em><\/p>\n\n\n\n<p><span class=\"has-inline-color has-vivid-cyan-blue-color\"><strong>Create an index.html with test Content<\/strong><\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim index.html\n###########\n&lt;h1&gt; This is my Apache Docker File &lt;\/h1&gt;\n###########<\/code><\/pre>\n\n\n\n<p><strong><span class=\"has-inline-color has-vivid-cyan-blue-color\">Create an Apache default conf as httpd.conf<\/span><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim httpd.conf\n###########\n&lt;VirtualHost *:80&gt;\n    DocumentRoot \"\/var\/www\/html\/\"\n    ServerName example.com\n    ServerAlias www.example.com\n    ErrorLog \"\/var\/log\/httpd\/error_log\"\n    CustomLog \"\/var\/log\/httpd\/access_log\" combined\n&lt;\/VirtualHost&gt;\n###########<\/code><\/pre>\n\n\n\n<p><strong><span class=\"has-inline-color has-vivid-cyan-blue-color\">Build the docker image<\/span><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker build -t apache:centos .<\/code><\/pre>\n\n\n\n<p><strong><span class=\"has-inline-color has-vivid-cyan-blue-color\">To check docker images<\/span><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker images<\/code><\/pre>\n\n\n\n<p><strong><span class=\"has-inline-color has-vivid-cyan-blue-color\">Run the container from the docker image<\/span><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker run -d  -p 80:80 apache:centos<\/code><\/pre>\n\n\n\n<p><em>Whereas:<br>apache= image name:tag (you can also use image id)<br>p = 80:80 ( binds port 80 of the running host to the TCP port 80 (apache) on the container.<br>d = Run container in the background and print the container ID<\/em><\/p>\n\n\n\n<p><strong><span class=\"has-inline-color has-vivid-cyan-blue-color\">To check running docker containers<\/span><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker ps<\/code><\/pre>\n\n\n\n<p><strong><span class=\"has-inline-color has-vivid-cyan-blue-color\">Test the apache image using<\/span><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http:\/\/SERVER-IP\/ OR http:\/\/example.com<\/code><\/pre>\n\n\n\n<p>Then it will give the content same as in index.html page, it is because we copied the index.html to the apache docker container using the Dockerfile.<\/p>\n\n\n\n<figure class=\"wp-block-pullquote is-style-default\"><blockquote class=\"has-text-color has-vivid-red-color\"><p><strong>Are you facing any issues with the Docker setup?<\/strong><\/p><cite><strong><a href=\"https:\/\/www.skynats.com\/contact-us\/\" target=\"_blank\" aria-label=\"undefined (opens in a new tab)\" rel=\"noreferrer noopener\">CONTACT US NOW<\/a><\/strong><\/cite><\/blockquote><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Apache is an opensource web server that is commonly used for webpage deployments. Apache does support almost all operating systems worldwide. Docker is an opensource virtualization tool in which users can create, run, and deploy applications or software in packages called containers. The containers can communicate with each other through proper channels This blog will [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[83],"class_list":["post-5227","post","type-post","status-publish","format-standard","hentry","category-blog","tag-apache-docker"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Create Apache Docker Image | Docker Support<\/title>\n<meta name=\"description\" content=\"Are you struggling with creating apache docker image on the server? Read our blog or contact our experts to get it fixed right now!!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.skynats.com\/blog\/how-to-create-apache-docker-image\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Create Apache Docker Image\" \/>\n<meta property=\"og:description\" content=\"Are you struggling with creating apache docker image on the server? Read our blog or contact our experts to get it fixed right now!!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.skynats.com\/blog\/how-to-create-apache-docker-image\/\" \/>\n<meta property=\"og:site_name\" content=\"Server Management Services | Cloud Management | Skynats\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/skynats\" \/>\n<meta property=\"article:published_time\" content=\"2020-07-21T11:02:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-21T11:14:00+00:00\" \/>\n<meta name=\"author\" content=\"Kevin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@skynatstech\" \/>\n<meta name=\"twitter:site\" content=\"@skynatstech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kevin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/how-to-create-apache-docker-image\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/how-to-create-apache-docker-image\\\/\"},\"author\":{\"name\":\"Kevin\",\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#\\\/schema\\\/person\\\/749ae0470320eb759ff1e07b8ea7fbe3\"},\"headline\":\"How to Create Apache Docker Image\",\"datePublished\":\"2020-07-21T11:02:16+00:00\",\"dateModified\":\"2021-09-21T11:14:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/how-to-create-apache-docker-image\\\/\"},\"wordCount\":397,\"publisher\":{\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#organization\"},\"keywords\":[\"apache docker\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/how-to-create-apache-docker-image\\\/\",\"url\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/how-to-create-apache-docker-image\\\/\",\"name\":\"How to Create Apache Docker Image | Docker Support\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#website\"},\"datePublished\":\"2020-07-21T11:02:16+00:00\",\"dateModified\":\"2021-09-21T11:14:00+00:00\",\"description\":\"Are you struggling with creating apache docker image on the server? Read our blog or contact our experts to get it fixed right now!!\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/how-to-create-apache-docker-image\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.skynats.com\\\/blog\\\/how-to-create-apache-docker-image\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/how-to-create-apache-docker-image\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Create Apache Docker Image\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/\",\"name\":\"Server Management Services | Cloud Management | Skynats\",\"description\":\"Server Management and Cloud Management\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#organization\",\"name\":\"Skynats Technologies\",\"url\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/08\\\/Sknats-Logo-New-whole.png\",\"contentUrl\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/08\\\/Sknats-Logo-New-whole.png\",\"width\":989,\"height\":367,\"caption\":\"Skynats Technologies\"},\"image\":{\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/skynats\",\"https:\\\/\\\/x.com\\\/skynatstech\",\"https:\\\/\\\/www.instagram.com\\\/skynatstech\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/skynats-technologies\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCvTAjrFJ4_E2MJKwlDHomlg\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#\\\/schema\\\/person\\\/749ae0470320eb759ff1e07b8ea7fbe3\",\"name\":\"Kevin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/37a006382b218eff478403065cc9d903f85dd0085cb2af7fee95b4537b581c13?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/37a006382b218eff478403065cc9d903f85dd0085cb2af7fee95b4537b581c13?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/37a006382b218eff478403065cc9d903f85dd0085cb2af7fee95b4537b581c13?s=96&d=mm&r=g\",\"caption\":\"Kevin\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Create Apache Docker Image | Docker Support","description":"Are you struggling with creating apache docker image on the server? Read our blog or contact our experts to get it fixed right now!!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.skynats.com\/blog\/how-to-create-apache-docker-image\/","og_locale":"en_US","og_type":"article","og_title":"How to Create Apache Docker Image","og_description":"Are you struggling with creating apache docker image on the server? Read our blog or contact our experts to get it fixed right now!!","og_url":"https:\/\/www.skynats.com\/blog\/how-to-create-apache-docker-image\/","og_site_name":"Server Management Services | Cloud Management | Skynats","article_publisher":"https:\/\/www.facebook.com\/skynats","article_published_time":"2020-07-21T11:02:16+00:00","article_modified_time":"2021-09-21T11:14:00+00:00","author":"Kevin","twitter_card":"summary_large_image","twitter_creator":"@skynatstech","twitter_site":"@skynatstech","twitter_misc":{"Written by":"Kevin","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.skynats.com\/blog\/how-to-create-apache-docker-image\/#article","isPartOf":{"@id":"https:\/\/www.skynats.com\/blog\/how-to-create-apache-docker-image\/"},"author":{"name":"Kevin","@id":"https:\/\/www.skynats.com\/blog\/#\/schema\/person\/749ae0470320eb759ff1e07b8ea7fbe3"},"headline":"How to Create Apache Docker Image","datePublished":"2020-07-21T11:02:16+00:00","dateModified":"2021-09-21T11:14:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.skynats.com\/blog\/how-to-create-apache-docker-image\/"},"wordCount":397,"publisher":{"@id":"https:\/\/www.skynats.com\/blog\/#organization"},"keywords":["apache docker"],"articleSection":["Blog"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.skynats.com\/blog\/how-to-create-apache-docker-image\/","url":"https:\/\/www.skynats.com\/blog\/how-to-create-apache-docker-image\/","name":"How to Create Apache Docker Image | Docker Support","isPartOf":{"@id":"https:\/\/www.skynats.com\/blog\/#website"},"datePublished":"2020-07-21T11:02:16+00:00","dateModified":"2021-09-21T11:14:00+00:00","description":"Are you struggling with creating apache docker image on the server? Read our blog or contact our experts to get it fixed right now!!","breadcrumb":{"@id":"https:\/\/www.skynats.com\/blog\/how-to-create-apache-docker-image\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.skynats.com\/blog\/how-to-create-apache-docker-image\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.skynats.com\/blog\/how-to-create-apache-docker-image\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.skynats.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Create Apache Docker Image"}]},{"@type":"WebSite","@id":"https:\/\/www.skynats.com\/blog\/#website","url":"https:\/\/www.skynats.com\/blog\/","name":"Server Management Services | Cloud Management | Skynats","description":"Server Management and Cloud Management","publisher":{"@id":"https:\/\/www.skynats.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.skynats.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.skynats.com\/blog\/#organization","name":"Skynats Technologies","url":"https:\/\/www.skynats.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.skynats.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.skynats.com\/blog\/wp-content\/uploads\/2021\/08\/Sknats-Logo-New-whole.png","contentUrl":"https:\/\/www.skynats.com\/blog\/wp-content\/uploads\/2021\/08\/Sknats-Logo-New-whole.png","width":989,"height":367,"caption":"Skynats Technologies"},"image":{"@id":"https:\/\/www.skynats.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/skynats","https:\/\/x.com\/skynatstech","https:\/\/www.instagram.com\/skynatstech\/","https:\/\/www.linkedin.com\/company\/skynats-technologies","https:\/\/www.youtube.com\/channel\/UCvTAjrFJ4_E2MJKwlDHomlg"]},{"@type":"Person","@id":"https:\/\/www.skynats.com\/blog\/#\/schema\/person\/749ae0470320eb759ff1e07b8ea7fbe3","name":"Kevin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/37a006382b218eff478403065cc9d903f85dd0085cb2af7fee95b4537b581c13?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/37a006382b218eff478403065cc9d903f85dd0085cb2af7fee95b4537b581c13?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/37a006382b218eff478403065cc9d903f85dd0085cb2af7fee95b4537b581c13?s=96&d=mm&r=g","caption":"Kevin"}}]}},"_links":{"self":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/5227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/comments?post=5227"}],"version-history":[{"count":0,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/5227\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/media?parent=5227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/categories?post=5227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/tags?post=5227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}