<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.define-technology.com/mediawiki-1.35.0/index.php?action=history&amp;feed=atom&amp;title=Docker%3A_Building_a_Server_with_Dockerfile</id>
	<title>Docker: Building a Server with Dockerfile - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.define-technology.com/mediawiki-1.35.0/index.php?action=history&amp;feed=atom&amp;title=Docker%3A_Building_a_Server_with_Dockerfile"/>
	<link rel="alternate" type="text/html" href="http://wiki.define-technology.com/mediawiki-1.35.0/index.php?title=Docker:_Building_a_Server_with_Dockerfile&amp;action=history"/>
	<updated>2026-05-04T18:49:54Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.0</generator>
	<entry>
		<id>http://wiki.define-technology.com/mediawiki-1.35.0/index.php?title=Docker:_Building_a_Server_with_Dockerfile&amp;diff=12171&amp;oldid=prev</id>
		<title>David: Created page with &quot;== Setting up a Nginx Webserver with Dockerfile == Let&#039;s build a static web server with a Dockerfile. The Dockerfile provides a set of instructions for Docker to run on a cont...&quot;</title>
		<link rel="alternate" type="text/html" href="http://wiki.define-technology.com/mediawiki-1.35.0/index.php?title=Docker:_Building_a_Server_with_Dockerfile&amp;diff=12171&amp;oldid=prev"/>
		<updated>2016-02-18T21:45:05Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Setting up a Nginx Webserver with Dockerfile == Let&amp;#039;s build a static web server with a Dockerfile. The Dockerfile provides a set of instructions for Docker to run on a cont...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Setting up a Nginx Webserver with Dockerfile ==&lt;br /&gt;
Let&amp;#039;s build a static web server with a Dockerfile. The Dockerfile provides a set of instructions for Docker to run on a container. This lets us automate installing items as if it were a bash script. &lt;br /&gt;
&lt;br /&gt;
Create a new directory and cd into it. Because we&amp;#039;re installing Nginx, let&amp;#039;s create a default configuration file that we&amp;#039;ll use for it.&lt;br /&gt;
&lt;br /&gt;
Create a file called default (the most basic nginx configuration file) &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
[root@blade02 ~]# mkdir nginx-dockerfile&lt;br /&gt;
[root@blade02 ~]# cd nginx-dockerfile/&lt;br /&gt;
[root@blade02 nginx-dockerfile]# vi default&lt;br /&gt;
[root@blade02 nginx-dockerfile]# cat default &lt;br /&gt;
server {&lt;br /&gt;
    root /var/www;&lt;br /&gt;
    index index.html index.htm;&lt;br /&gt;
&lt;br /&gt;
    # Make site accessible from http://localhost/&lt;br /&gt;
    server_name localhost;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        # First attempt to serve request as file, then&lt;br /&gt;
        # as directory, then fall back to index.html&lt;br /&gt;
        try_files $uri $uri/ /index.html;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now lets create the Docker file; &lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
[root@blade02 nginx-dockerfile]# cat Dockerfile &lt;br /&gt;
FROM ubuntu&lt;br /&gt;
&lt;br /&gt;
RUN echo &amp;quot;deb http://archive.ubuntu.com/ubuntu precise main universe&amp;quot; &amp;gt; /etc/apt/sources.list&lt;br /&gt;
RUN apt-get update&lt;br /&gt;
RUN apt-get -y install nginx&lt;br /&gt;
&lt;br /&gt;
RUN echo &amp;quot;daemon off;&amp;quot; &amp;gt;&amp;gt; /etc/nginx/nginx.conf&lt;br /&gt;
RUN mkdir /etc/nginx/ssl&lt;br /&gt;
ADD default /etc/nginx/sites-available/default&lt;br /&gt;
&lt;br /&gt;
EXPOSE 80&lt;br /&gt;
&lt;br /&gt;
CMD [&amp;quot;nginx&amp;quot;]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What&amp;#039;s this doing?&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;FROM&amp;#039;&amp;#039;&amp;#039; will tell Docker what image (and tag in this case) to base this off of&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;RUN&amp;#039;&amp;#039;&amp;#039; will run the given command (as user &amp;quot;root&amp;quot;) using sh -c &amp;quot;your-given-command&amp;quot;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;ADD&amp;#039;&amp;#039;&amp;#039; will copy a file from the host machine into the container. This is handy for configuration files or scripts to run, such as a process watcher like supervisord, systemd, upstart, forever (etc)&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;EXPOSE&amp;#039;&amp;#039;&amp;#039;  will expose a port to the host machine. You can expose multiple ports like so: EXPOSE 80 443 8888&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;CMD&amp;#039;&amp;#039;&amp;#039;  will run a command (not using sh -c). This is usually your long-running process. In this case, we&amp;#039;re simply starting Nginx.&lt;br /&gt;
&lt;br /&gt;
In production, we&amp;#039;d want something watching the nginx process in case it fails&lt;br /&gt;
&lt;br /&gt;
We can now build a new docker image from this Dockerfile&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
docker build -t nginx-example .&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>David</name></author>
	</entry>
</feed>