Squashed commit of the following:
commit 3f9e9185fe7ee51f2fe55f0fc0d4fffdc4f289dc Author: Nathan Hsieh <hsieh.nathan@gmail.com> Date: Mon Oct 6 10:57:35 2014 -0700 changed the title of back buttons commit f86934424e85931ec293e711ceaa93ee920828fb Author: Nathan Hsieh <hsieh.nathan@gmail.com> Date: Mon Oct 6 10:53:15 2014 -0700 Finished level 2, refactored tests commit 8f502bce05293cccaf200b69ce5f5826eee72484 Author: Nathan Hsieh <hsieh.nathan@gmail.com> Date: Mon Oct 6 08:52:37 2014 -0700 stylized better and added level 2 commit 07b2276b346c34c0cc0faa57500c40e120e77888 Author: Nathan Hsieh <hsieh.nathan@gmail.com> Date: Fri Oct 3 18:17:29 2014 -0700 broke tutorial tests styles commit 35d84147dc2f65b0ffeea5faf304add903219b1e Author: Nathan Hsieh <hsieh.nathan@gmail.com> Date: Fri Oct 3 17:23:48 2014 -0700 structured test level1 md file commit 808d01b0d55d67eb1017f290a29da6c7d38565f2 Author: Nathan Hsieh <hsieh.nathan@gmail.com> Date: Fri Oct 3 17:15:46 2014 -0700 Modified files and integrated tutorial through new page commit 0f0093f2882489c3eeb6f8870f2b8aa64dc939a3 Author: Nathan Hsieh <hsieh.nathan@gmail.com> Date: Thu Oct 2 14:34:44 2014 -0700 more refactoring commit 5a9b98e55ebd455ccf2c0ced20f984545a0b6d71 Author: Nathan Hsieh <hsieh.nathan@gmail.com> Date: Thu Oct 2 11:46:58 2014 -0700 clean js code commit af3bbd8d5e1dffdaa1780f83b909ff566906e513 Author: Nathan Hsieh <hsieh.nathan@gmail.com> Date: Thu Oct 2 11:26:39 2014 -0700 level 1 cleanup commit c4852a7766ab4fbd978d65c8352ace05eb427ef5 Author: Nathan Hsieh <hsieh.nathan@gmail.com> Date: Thu Oct 2 11:20:17 2014 -0700 fixed up fill-in level1 commit 7f02d80942549dec9c05f784b777fcb32d5bb81b Author: Nathan Hsieh <hsieh.nathan@gmail.com> Date: Wed Oct 1 17:45:42 2014 -0700 added dockerfile tut, stylized lesson1 Questions Signed-off-by: Nathan Hsieh <hsieh.nathan@gmail.com>
This commit is contained in:
parent
8ceb213b3e
commit
c257dcc9a4
9 changed files with 581 additions and 0 deletions
|
@ -59,6 +59,8 @@ pages:
|
||||||
- ['userguide/dockerlinks.md', 'User Guide', 'Linking containers together' ]
|
- ['userguide/dockerlinks.md', 'User Guide', 'Linking containers together' ]
|
||||||
- ['userguide/dockervolumes.md', 'User Guide', 'Managing data in containers' ]
|
- ['userguide/dockervolumes.md', 'User Guide', 'Managing data in containers' ]
|
||||||
- ['userguide/dockerrepos.md', 'User Guide', 'Working with Docker Hub' ]
|
- ['userguide/dockerrepos.md', 'User Guide', 'Working with Docker Hub' ]
|
||||||
|
- ['userguide/level1.md', '**HIDDEN**' ]
|
||||||
|
- ['userguide/level2.md', '**HIDDEN**' ]
|
||||||
|
|
||||||
# Docker Hub docs:
|
# Docker Hub docs:
|
||||||
- ['docker-hub/index.md', 'Docker Hub', 'Docker Hub' ]
|
- ['docker-hub/index.md', 'Docker Hub', 'Docker Hub' ]
|
||||||
|
|
|
@ -168,6 +168,8 @@ update and create images.
|
||||||
1. We can update a container created from an image and commit the results to an image.
|
1. We can update a container created from an image and commit the results to an image.
|
||||||
2. We can use a `Dockerfile` to specify instructions to create an image.
|
2. We can use a `Dockerfile` to specify instructions to create an image.
|
||||||
|
|
||||||
|
Test your understanding [here](/userguide/level1)!
|
||||||
|
|
||||||
### Updating and committing an image
|
### Updating and committing an image
|
||||||
|
|
||||||
To update an image we first need to create a container from the image
|
To update an image we first need to create a container from the image
|
||||||
|
@ -478,6 +480,10 @@ We can then create a container from our new image.
|
||||||
> To help you write a clear, readable, maintainable `Dockerfile`, we've also
|
> To help you write a clear, readable, maintainable `Dockerfile`, we've also
|
||||||
> written a [`Dockerfile` Best Practices guide](/articles/dockerfile_best-practices).
|
> written a [`Dockerfile` Best Practices guide](/articles/dockerfile_best-practices).
|
||||||
|
|
||||||
|
### Test your understanding
|
||||||
|
|
||||||
|
See how well you understand the material by taking [this short quiz](/userguide/level1)!
|
||||||
|
|
||||||
## Setting tags on an image
|
## Setting tags on an image
|
||||||
|
|
||||||
You can also add a tag to an existing image after you commit or build it. We
|
You can also add a tag to an existing image after you commit or build it. We
|
||||||
|
@ -535,3 +541,4 @@ by linking together multiple Docker containers.
|
||||||
|
|
||||||
Go to [Linking Containers Together](/userguide/dockerlinks).
|
Go to [Linking Containers Together](/userguide/dockerlinks).
|
||||||
|
|
||||||
|
|
||||||
|
|
72
docs/sources/userguide/level1.md
Normal file
72
docs/sources/userguide/level1.md
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
page_title: Docker Images Test
|
||||||
|
page_description: How to work with Docker images.
|
||||||
|
page_keywords: documentation, docs, the docker guide, docker guide, docker, docker platform, virtualization framework, docker.io, Docker images, Docker image, image management, Docker repos, Docker repositories, docker, docker tag, docker tags, Docker Hub, collaboration
|
||||||
|
|
||||||
|
<a title="back" class="btn btn-primary back" href="/userguide/dockerimages/#creating-our-own-images">Back</a>
|
||||||
|
|
||||||
|
# Test Yourself
|
||||||
|
|
||||||
|
## Test your Dockerfile skills - Level 1
|
||||||
|
|
||||||
|
### Questions
|
||||||
|
|
||||||
|
<div name="level1_questions">
|
||||||
|
What is the Dockerfile instruction to specify the base image ?<br />
|
||||||
|
<input type="text" class="level" id="level1_q0"/>
|
||||||
|
<div class="alert alert-error level_error" id="level1_error0" style="display:none;">The right answer was <code>FROM</code></div>
|
||||||
|
<br>
|
||||||
|
What is the Dockerfile instruction to execute any commands on the current image and commit the results?<br />
|
||||||
|
<input type="text" class="level" id="level1_q1"/>
|
||||||
|
<div class="alert alert-error level_error" id="level1_error1" style="display:none;">The right answer was <code>RUN</code></div>
|
||||||
|
<br>
|
||||||
|
What is the Dockerfile instruction to specify the maintainer of the Dockerfile?<br />
|
||||||
|
<input type="text" class="level" id="level1_q2"/>
|
||||||
|
<div class="alert alert-error level_error" id="level1_error2" style="display:none;">The right answer was <code>MAINTAINER</code></div>
|
||||||
|
<br>
|
||||||
|
What is the character used to add comment in Dockerfiles?<br />
|
||||||
|
<input type="text" class="level" id="level1_q3"/>
|
||||||
|
<div class="alert alert-error level_error" id="level1_error3" style="display:none;">The right answer was <code>#</code></div>
|
||||||
|
<p>
|
||||||
|
<div class="alert alert-success" id="all_good" style="display:none;">Congratulations, you made no mistake!<br />
|
||||||
|
Tell the world <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.docker.io/learn/dockerfile/level1/" data-text="I just successfully answered questions of the #Dockerfile tutorial Level 1. What's your score?" data-via="docker" >Tweet</a><br />
|
||||||
|
And try the next challenge: <a href="#fill_the_dockerfile">Fill the Dockerfile</a>
|
||||||
|
</div>
|
||||||
|
<div class="alert alert-error" id="no_good" style="display:none;">Your Dockerfile skills are not yet perfect, try to take the time to read this tutorial again.</div>
|
||||||
|
<div class="alert alert-block" id="some_good" style="display:none;">You're almost there! Read carefully the sections corresponding to your errors, and take the test again!</div>
|
||||||
|
</p>
|
||||||
|
<button class="btn btn-primary" id="check_level1_questions">Check your answers</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
### Fill the Dockerfile
|
||||||
|
Your best friend Eric Bardin sent you a Dockerfile, but some parts were lost in the ocean. Can you find the missing parts?
|
||||||
|
<div class="form-inline">
|
||||||
|
<pre>
|
||||||
|
# This is a Dockerfile to create an image with Memcached and Emacs installed. <br>
|
||||||
|
# VERSION 1.0<br>
|
||||||
|
# use the ubuntu base image provided by dotCloud
|
||||||
|
<input type="text" class="l_fill" id="from" /> ub<input type="text" class="l_fill" id="ubuntu" /><br>
|
||||||
|
<input type="text" class="l_fill" id="maintainer" /> E<input type="text" class="l_fill" id="eric" /> B<input type="text" class="l_fill" id="bardin" />, eric.bardin@dotcloud.com<br>
|
||||||
|
# make sure the package repository is up to date
|
||||||
|
<input type="text" class="l_fill" id="run0"/> echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
|
||||||
|
<input type="text" class="l_fill" id="run1" /> apt-get update<br>
|
||||||
|
# install memcached
|
||||||
|
RUN apt-get install -y <input type="text" class="l_fill" id="memcached" /><br>
|
||||||
|
# install emacs
|
||||||
|
<input type="text" class="l_fill" id="run2"/> apt-get install -y emacs23
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="alert alert-success" id="dockerfile_ok" style="display:none;">Congratulations, you successfully restored Eric's Dockerfile! You are ready to containerize the world!.<br />
|
||||||
|
Tell the world! <a href="https://twitter.com/share" class="twitter-share-button" data-url="https://www.docker.io/learn/dockerfile/level1/" data-text="I just successfully completed the 'Fill the Dockerfile' challenge of the #Dockerfile tutorial Level 1" data-via="docker" >Tweet</a>
|
||||||
|
</div>
|
||||||
|
<div class="alert alert-error" id="dockerfile_ko" style="display:none;">Wooops, there are one or more errors in the Dockerfile. Try again.</div>
|
||||||
|
<br>
|
||||||
|
<button class="btn btn-primary" id="check_level1_fill">Check the Dockerfile</button></p>
|
||||||
|
|
||||||
|
## What's next?
|
||||||
|
|
||||||
|
<p>In the next level, we will go into more detail about how to specify which command should be executed when the container starts,
|
||||||
|
which user to use, and how expose a particular port.</p>
|
||||||
|
|
||||||
|
<a title="back" class="btn btn-primary back" href="/userguide/dockerimages/#creating-our-own-images">Back</a>
|
||||||
|
<a title="next level" class="btn btn-primary" href="/userguide/level2">Go to the next level</a>
|
97
docs/sources/userguide/level2.md
Normal file
97
docs/sources/userguide/level2.md
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
page_title: Docker Images Test
|
||||||
|
page_description: How to work with Docker images.
|
||||||
|
page_keywords: documentation, docs, the docker guide, docker guide, docker, docker platform, virtualization framework, docker.io, Docker images, Docker image, image management, Docker repos, Docker repositories, docker, docker tag, docker tags, Docker Hub, collaboration
|
||||||
|
|
||||||
|
<a title="back" class="btn btn-primary back" href="/userguide/dockerimages/#creating-our-own-images">Back</a>
|
||||||
|
|
||||||
|
#Test Yourself
|
||||||
|
|
||||||
|
## Test your Dockerfile skills - Level 2
|
||||||
|
|
||||||
|
### Questions:
|
||||||
|
|
||||||
|
<div class="level_questions">
|
||||||
|
What is the Dockerfile instruction to specify the base image?<br>
|
||||||
|
<input type="text" class="level">
|
||||||
|
<div style="display:none;" id="level2_error0" class="alert alert-error level_error">The right answer was <code>FROM</code></div><br>
|
||||||
|
Which Dockerfile instruction sets the default command for your image?<br>
|
||||||
|
<input type="text" class="level">
|
||||||
|
<div style="display:none;" id="level2_error4" class="alert alert-error level_error">The right answer was <code>ENTRYPOINT</code> or <code>CMD</code></div><br>
|
||||||
|
What is the character used to add comments in Dockerfiles?<br>
|
||||||
|
<input type="text" class="level">
|
||||||
|
<div style="display:none;" id="level2_error3" class="alert alert-error level_error">The right answer was <code>#</code></div><br>
|
||||||
|
Which Dockerfile instruction sets the username to use when running the image?<br>
|
||||||
|
<input type="text" class="level">
|
||||||
|
<div style="display:none;" id="level2_error5" class="alert alert-error level_error">The right answer was <code>USER</code></div><br>
|
||||||
|
What is the Dockerfile instruction to execute any command on the current image and commit the results?<br>
|
||||||
|
<input type="text" class="level">
|
||||||
|
<div style="display:none;" id="level2_error1" class="alert alert-error level_error">The right answer was <code>RUN</code></div><br>
|
||||||
|
Which Dockerfile instruction sets ports to be exposed when running the image?<br>
|
||||||
|
<input type="text" class="level">
|
||||||
|
<div style="display:none;" id="level2_error6" class="alert alert-error level_error">The right answer was <code>EXPOSE</code></div><br>
|
||||||
|
What is the Dockerfile instruction to specify the maintainer of the Dockerfile?<br>
|
||||||
|
<input type="text" class="level">
|
||||||
|
<div style="display:none;" id="level2_error2" class="alert alert-error level_error">The right answer was <code>MAINTAINER</code></div><br>
|
||||||
|
Which Dockerfile instruction lets you trigger a command as soon as the container starts?<br>
|
||||||
|
<input type="text" class="level">
|
||||||
|
<div style="display:none;" id="level2_error7" class="alert alert-error level_error">The right answer was <code>ENTRYPOINT</code> or <code>CMD</code></div><br>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
<div class="alert alert-success" id="all_good" style="display:none;">Congratulations, you made no mistake!<br />
|
||||||
|
Tell the world <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.docker.io/learn/dockerfile/level1/" data-text="I just successfully answered questions of the #Dockerfile tutorial Level 1. What's your score?" data-via="docker" >Tweet</a><br />
|
||||||
|
And try the next challenge: <a href="#fill_the_dockerfile">Fill the Dockerfile</a>
|
||||||
|
</div>
|
||||||
|
<div class="alert alert-error" id="no_good" style="display:none;">Your Dockerfile skills are not yet perfect, try to take the time to read this tutorial again.</div>
|
||||||
|
<div class="alert alert-block" id="some_good" style="display:none;">You're almost there! Read carefully the sections corresponding to your errors, and take the test again!</div>
|
||||||
|
</p>
|
||||||
|
<button class="btn btn-primary" id="check_level2_questions">Check your answers</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
### Fill the Dockerfile
|
||||||
|
<br>
|
||||||
|
Your best friend Roberto Hashioka sent you a Dockerfile, but some parts were lost in the ocean. Can you find the missing parts?
|
||||||
|
<div class="form-inline">
|
||||||
|
<pre>
|
||||||
|
# Redis
|
||||||
|
#
|
||||||
|
# VERSION 0.42
|
||||||
|
#
|
||||||
|
# use the ubuntu base image provided by dotCloud
|
||||||
|
<input id="from" class="l_fill" type="text"> ub<input id="ubuntu" class="l_fill" type="text"><br>
|
||||||
|
MAINT<input id="maintainer" class="l_fill" type="text"> Ro<input id="roberto" class="l_fill" type="text"> Ha<input id="hashioka" class="l_fill" type="text"> roberto.hashioka@dotcloud.com<br>
|
||||||
|
# make sure the package repository is up to date
|
||||||
|
<input id="run0" class="l_fill" type="text"> echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
|
||||||
|
<input id="run1" class="l_fill" type="text"> apt-get update<br>
|
||||||
|
# install wget (required for redis installation)
|
||||||
|
<input id="run2" class="l_fill" type="text"> apt-get install -y wget<br>
|
||||||
|
# install make (required for redis installation)
|
||||||
|
<input id="run3" class="l_fill" type="text"> apt-get install -y make<br>
|
||||||
|
# install gcc (required for redis installation)
|
||||||
|
RUN apt-get install -y <input id="gcc" class="l_fill" type="text"><br>
|
||||||
|
# install apache2
|
||||||
|
<input id="run4" class="l_fill" type="text"> wget http://download.redis.io/redis-stable.tar.gz
|
||||||
|
<input id="run5" class="l_fill" type="text">tar xvzf redis-stable.tar.gz
|
||||||
|
<input id="run6" class="l_fill" type="text">cd redis-stable && make && make install<br>
|
||||||
|
# launch redis when starting the image
|
||||||
|
<input id="entrypoint" class="l_fill" type="text"> ["redis-server"]<br>
|
||||||
|
# run as user dameon
|
||||||
|
<input id="user" class="l_fill" type="text"> daemon<br>
|
||||||
|
# expose port 6379
|
||||||
|
<input id="expose" class="l_fill" type="text"> 6379
|
||||||
|
</pre>
|
||||||
|
<div class="alert alert-success" id="dockerfile_ok" style="display:none;">Congratulations, you successfully restored Roberto's Dockerfile! You are ready to containerize the world!.<br />
|
||||||
|
Tell the world! <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.docker.io/learn/dockerfile/level2/" data-text="I just successfully completed the 'Dockerfill' challenge of the #Dockerfile tutorial Level 2" data-via="docker" >Tweet</a>
|
||||||
|
</div>
|
||||||
|
<div class="alert alert-error" id="dockerfile_ko" style="display:none;">Wooops, there are one or more errors in the Dockerfile. Try again.</div>
|
||||||
|
<br>
|
||||||
|
<button class="btn btn-primary" id="check_level2_fill">Check the Dockerfile</button></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## What's next?
|
||||||
|
<p>
|
||||||
|
Thanks for going through our tutorial! We will be posting Level 3 shortly. Follow us on twitter<br>
|
||||||
|
<a href="https://twitter.com/docker" class="twitter-follow-button" data-show-count="false">Follow @docker</a>
|
||||||
|
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
|
||||||
|
</p>
|
||||||
|
<p>In the meantime, check out this <a href="http://crosbymichael.com/dockerfile-best-practices.html">blog post</a> by Michael Crosby that describes Dockerfile Best Practices.</p>
|
||||||
|
<a title="creating our own images" class="btn btn-primary" href="/userguide/dockerimages/#creating-our-own-images">Back to the Docs!</a>
|
4
docs/theme/mkdocs/base.html
vendored
4
docs/theme/mkdocs/base.html
vendored
|
@ -17,6 +17,7 @@
|
||||||
<link href="/css/bootstrap-custom.css" rel="stylesheet">
|
<link href="/css/bootstrap-custom.css" rel="stylesheet">
|
||||||
<link href="/css/main.css" rel="stylesheet">
|
<link href="/css/main.css" rel="stylesheet">
|
||||||
<link href="/css/prettify-1.0.css" rel="stylesheet">
|
<link href="/css/prettify-1.0.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" type="text/css" href="/css/dockerfile_tutorial.css">
|
||||||
<link href="/tipuesearch/tipuesearch.css" rel="stylesheet">
|
<link href="/tipuesearch/tipuesearch.css" rel="stylesheet">
|
||||||
<link href="/css/docs.css" rel="stylesheet">
|
<link href="/css/docs.css" rel="stylesheet">
|
||||||
<link rel="shortcut icon" href="{{ site_favicon }}">
|
<link rel="shortcut icon" href="{{ site_favicon }}">
|
||||||
|
@ -102,9 +103,12 @@
|
||||||
{% include "footer.html" %}
|
{% include "footer.html" %}
|
||||||
|
|
||||||
<script src="/js/jquery-1.10.2.min.js"></script>
|
<script src="/js/jquery-1.10.2.min.js"></script>
|
||||||
|
<script src="/js/jquery.cookie.js" ></script>
|
||||||
<script src="/js/jquery-scrolltofixed-min.js"></script>
|
<script src="/js/jquery-scrolltofixed-min.js"></script>
|
||||||
<script src="/js/bootstrap-3.0.3.min.js"></script>
|
<script src="/js/bootstrap-3.0.3.min.js"></script>
|
||||||
<script src="/js/prettify-1.0.min.js"></script>
|
<script src="/js/prettify-1.0.min.js"></script>
|
||||||
|
<script src="/js/dockerfile_tutorial.js"></script>
|
||||||
|
<script src="/js/dockerfile_tutorial_level.js"></script>
|
||||||
<script src="/js/base.js"></script>
|
<script src="/js/base.js"></script>
|
||||||
<script src="/tipuesearch/tipuesearch_set.js"></script>
|
<script src="/tipuesearch/tipuesearch_set.js"></script>
|
||||||
<script src="/tipuesearch/tipuesearch.min.js"></script>
|
<script src="/tipuesearch/tipuesearch.min.js"></script>
|
||||||
|
|
59
docs/theme/mkdocs/css/dockerfile_tutorial.css
vendored
Normal file
59
docs/theme/mkdocs/css/dockerfile_tutorial.css
vendored
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
pre {
|
||||||
|
background-color: #F5F5F5;
|
||||||
|
border: 1px solid rgba(0, 0, 0, 0.15);
|
||||||
|
border-radius: 4px 4px 4px 4px;
|
||||||
|
display: block;
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 20px;
|
||||||
|
margin: 0 0 10px;
|
||||||
|
padding: 9.5px;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-break: break-all;
|
||||||
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
|
code, pre {
|
||||||
|
border-radius: 3px 3px 3px 3px;
|
||||||
|
color: #333333;
|
||||||
|
font-family: Monaco,Menlo,Consolas,"Courier New",monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
padding: 0 3px 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.terminal {
|
||||||
|
color: #AAAAAA;
|
||||||
|
background-color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.terminal span.command {
|
||||||
|
color: white;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error_input {
|
||||||
|
border-color: #B94A48 !important;
|
||||||
|
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
input.level {
|
||||||
|
width: 150px;
|
||||||
|
height: 2.5em;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
div.level_error {
|
||||||
|
width: 300px;
|
||||||
|
display: inline-block;
|
||||||
|
padding: 7px 12px;
|
||||||
|
}
|
||||||
|
.alert {
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
#check_level_questions {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
.form-inline input.l_fill {
|
||||||
|
height: 20px;
|
||||||
|
border-radius: 0;
|
||||||
|
width: 90px;
|
||||||
|
margin-right: 0;
|
||||||
|
padding: 0 0 2px 0;
|
||||||
|
}
|
74
docs/theme/mkdocs/js/dockerfile_tutorial.js
vendored
Executable file
74
docs/theme/mkdocs/js/dockerfile_tutorial.js
vendored
Executable file
|
@ -0,0 +1,74 @@
|
||||||
|
function clean_input(i) {
|
||||||
|
return i.replace(/^\s+|\s+$/g, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
function clean_up(str){
|
||||||
|
return clean_input(str).toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
function dockerfile_log(level, item, errors)
|
||||||
|
{
|
||||||
|
var logUrl = '/tutorial/api/dockerfile_event/';
|
||||||
|
$.ajax({
|
||||||
|
url: logUrl,
|
||||||
|
type: "POST",
|
||||||
|
cache:false,
|
||||||
|
data: {
|
||||||
|
'errors': errors,
|
||||||
|
'level': level,
|
||||||
|
'item': item,
|
||||||
|
},
|
||||||
|
}).done( function() { } );
|
||||||
|
}
|
||||||
|
|
||||||
|
function validate_email(email)
|
||||||
|
{
|
||||||
|
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||||
|
return re.test(email);
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
/* prepare to send the csrf-token on each ajax-request */
|
||||||
|
var csrftoken = $.cookie('csrftoken');
|
||||||
|
$.ajaxSetup({
|
||||||
|
headers: { 'X-CSRFToken': csrftoken }
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#send_email").click( function()
|
||||||
|
{
|
||||||
|
$('#email_invalid').hide();
|
||||||
|
$('#email_already_registered').hide();
|
||||||
|
$('#email_registered').hide();
|
||||||
|
|
||||||
|
email = $('#email').val();
|
||||||
|
if (!validate_email(email))
|
||||||
|
{
|
||||||
|
$('#email_invalid').show();
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
|
||||||
|
var emailUrl = '/tutorial/api/subscribe/';
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: emailUrl,
|
||||||
|
type: "POST",
|
||||||
|
cache:false,
|
||||||
|
data: {
|
||||||
|
'email': email,
|
||||||
|
'from_level': $(this).data('level')
|
||||||
|
},
|
||||||
|
}).done( function(data ) {
|
||||||
|
if (data == 1) // already registered
|
||||||
|
{
|
||||||
|
$('#email_already_registered').show();
|
||||||
|
}
|
||||||
|
else if (data == 0) // registered ok
|
||||||
|
{
|
||||||
|
$('#email_registered').show();
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
|
return (true);
|
||||||
|
});
|
||||||
|
})
|
176
docs/theme/mkdocs/js/dockerfile_tutorial_level.js
vendored
Normal file
176
docs/theme/mkdocs/js/dockerfile_tutorial_level.js
vendored
Normal file
|
@ -0,0 +1,176 @@
|
||||||
|
function check_form1 ()
|
||||||
|
{
|
||||||
|
$('#level1_error0').hide();
|
||||||
|
$('#level1_error1').hide();
|
||||||
|
$('#level1_error2').hide();
|
||||||
|
$('#level1_error3').hide();
|
||||||
|
|
||||||
|
$('#no_good').hide();
|
||||||
|
$('#some_good').hide();
|
||||||
|
$('#all_good').hide();
|
||||||
|
|
||||||
|
var a = clean_input($('#level1_q0').val()).toUpperCase();
|
||||||
|
var b = clean_input($('#level1_q1').val()).toUpperCase();
|
||||||
|
var c = clean_input($('#level1_q2').val()).toUpperCase();
|
||||||
|
var d = clean_input($('#level1_q3').val());
|
||||||
|
var points = 0;
|
||||||
|
|
||||||
|
if (a == 'FROM'){
|
||||||
|
points = points + 1;
|
||||||
|
} else {
|
||||||
|
$('#level1_error0').show();
|
||||||
|
}
|
||||||
|
if (b == 'RUN') {
|
||||||
|
points = points + 1;
|
||||||
|
} else {
|
||||||
|
$('#level1_error1').show();
|
||||||
|
}
|
||||||
|
if (c == 'MAINTAINER') {
|
||||||
|
points = points + 1;
|
||||||
|
} else {
|
||||||
|
$('#level1_error2').show();
|
||||||
|
}
|
||||||
|
if (d == '#') {
|
||||||
|
points = points + 1;
|
||||||
|
} else {
|
||||||
|
$('#level1_error3').show();
|
||||||
|
}
|
||||||
|
if (points == 4) {// all good
|
||||||
|
$('#all_good').show();
|
||||||
|
} else if (points == 0) { // nothing good
|
||||||
|
$('#no_good').show();
|
||||||
|
} else {// some good some bad
|
||||||
|
$('#some_good').show();
|
||||||
|
}
|
||||||
|
return (4 - points);
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_form2 ()
|
||||||
|
{
|
||||||
|
$('.level_questions .alert').hide();
|
||||||
|
|
||||||
|
var answers = {};
|
||||||
|
answers[0] = ['FROM'];
|
||||||
|
answers[1] = ['ENTRYPOINT', 'CMD'];
|
||||||
|
answers[2] = ['#'];
|
||||||
|
answers[3] = ['USER'];
|
||||||
|
answers[4] = ['RUN'];
|
||||||
|
answers[5] = ['EXPOSE'];
|
||||||
|
answers[6] = ['MAINTAINER'];
|
||||||
|
answers[7] = ['ENTRYPOINT', 'CMD'];
|
||||||
|
|
||||||
|
var points = 0;
|
||||||
|
|
||||||
|
$.each($(".level"), function(num, input){
|
||||||
|
var cleaned = clean_up(input.value);
|
||||||
|
if ($.inArray(cleaned, answers[num]) == -1) {
|
||||||
|
$( $(".level_error")[num]).show()
|
||||||
|
$(input).addClass("error_input");
|
||||||
|
} else {
|
||||||
|
$( $(".level_error")[num]).hide()
|
||||||
|
$(input).removeClass("error_input");
|
||||||
|
points += 1;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (points == 8) // all good
|
||||||
|
{
|
||||||
|
$('#all_good').show();
|
||||||
|
}
|
||||||
|
else if (points == 0) // nothing good
|
||||||
|
{
|
||||||
|
$('#no_good').show();
|
||||||
|
}
|
||||||
|
else // some good some bad
|
||||||
|
{
|
||||||
|
$('#some_good').show();
|
||||||
|
}
|
||||||
|
return (8- points);
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_fill(answers)
|
||||||
|
{
|
||||||
|
$('#dockerfile_ok').hide();
|
||||||
|
$('#dockerfile_ko').hide();
|
||||||
|
|
||||||
|
var errors = 0;
|
||||||
|
|
||||||
|
$.each($(".l_fill"), function(num, input){
|
||||||
|
var cleaned = clean_up(input.value);
|
||||||
|
var id = input.id;
|
||||||
|
if (answers[id] != cleaned) {
|
||||||
|
$(input).addClass("error_input");
|
||||||
|
errors += 1;
|
||||||
|
} else {
|
||||||
|
$(input).removeClass("error_input");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (errors != 0)
|
||||||
|
{
|
||||||
|
$('#dockerfile_ko').show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$('#dockerfile_ok').show();
|
||||||
|
}
|
||||||
|
return (errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
$("#check_level1_questions").click( function(){
|
||||||
|
errors = check_form1();
|
||||||
|
dockerfile_log(1, '1_questions', errors);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$("#check_level1_fill").click( function(){
|
||||||
|
var answers = {};
|
||||||
|
answers['from'] = 'FROM';
|
||||||
|
answers['ubuntu'] = 'UNTU';
|
||||||
|
answers['maintainer'] = 'MAINTAINER';
|
||||||
|
answers['eric'] = 'RIC';
|
||||||
|
answers['bardin'] = 'ARDIN';
|
||||||
|
answers['run0'] = 'RUN';
|
||||||
|
answers['run1'] = 'RUN';
|
||||||
|
answers['run2'] = 'RUN';
|
||||||
|
answers['memcached'] = 'MEMCACHED';
|
||||||
|
|
||||||
|
var errors = check_fill(answers);
|
||||||
|
dockerfile_log(1, '2_fill', errors);
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#check_level2_questions").click( function(){
|
||||||
|
errors = check_form2();
|
||||||
|
dockerfile_log(2, '1_questions', errors);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$("#check_level2_fill").click( function(){
|
||||||
|
var answers = {};
|
||||||
|
answers['from'] = "FROM";
|
||||||
|
answers['ubuntu'] = "UNTU";
|
||||||
|
answers['maintainer'] = "AINER";
|
||||||
|
answers['roberto'] = "BERTO";
|
||||||
|
answers['hashioka'] = "SHIOKA";
|
||||||
|
answers['run0'] = "RUN";
|
||||||
|
answers['run1'] = "RUN";
|
||||||
|
answers['run2'] = "RUN";
|
||||||
|
answers['run3'] = "RUN";
|
||||||
|
answers['run4'] = "RUN";
|
||||||
|
answers['run5'] = "RUN";
|
||||||
|
answers['run6'] = "RUN";
|
||||||
|
answers['entrypoint'] = "ENTRYPOINT";
|
||||||
|
answers['user'] = "USER";
|
||||||
|
answers['expose'] = "EXPOSE";
|
||||||
|
answers['gcc'] = "GCC";
|
||||||
|
|
||||||
|
var errors = check_fill(answers);
|
||||||
|
dockerfile_log(2, '2_fill', errors);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".btn.btn-primary.back").click( function(event){
|
||||||
|
event.preventDefault();
|
||||||
|
window.history.back();
|
||||||
|
})
|
||||||
|
});
|
90
docs/theme/mkdocs/js/jquery.cookie.js
vendored
Normal file
90
docs/theme/mkdocs/js/jquery.cookie.js
vendored
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
/*!
|
||||||
|
* jQuery Cookie Plugin v1.3.1
|
||||||
|
* https://github.com/carhartl/jquery-cookie
|
||||||
|
*
|
||||||
|
* Copyright 2013 Klaus Hartl
|
||||||
|
* Released under the MIT license
|
||||||
|
*/
|
||||||
|
(function ($, document, undefined) {
|
||||||
|
|
||||||
|
var pluses = /\+/g;
|
||||||
|
|
||||||
|
function raw(s) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
function decoded(s) {
|
||||||
|
return unRfc2068(decodeURIComponent(s.replace(pluses, ' ')));
|
||||||
|
}
|
||||||
|
|
||||||
|
function unRfc2068(value) {
|
||||||
|
if (value.indexOf('"') === 0) {
|
||||||
|
// This is a quoted cookie as according to RFC2068, unescape
|
||||||
|
value = value.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function fromJSON(value) {
|
||||||
|
return config.json ? JSON.parse(value) : value;
|
||||||
|
}
|
||||||
|
|
||||||
|
var config = $.cookie = function (key, value, options) {
|
||||||
|
|
||||||
|
// write
|
||||||
|
if (value !== undefined) {
|
||||||
|
options = $.extend({}, config.defaults, options);
|
||||||
|
|
||||||
|
if (value === null) {
|
||||||
|
options.expires = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof options.expires === 'number') {
|
||||||
|
var days = options.expires, t = options.expires = new Date();
|
||||||
|
t.setDate(t.getDate() + days);
|
||||||
|
}
|
||||||
|
|
||||||
|
value = config.json ? JSON.stringify(value) : String(value);
|
||||||
|
|
||||||
|
return (document.cookie = [
|
||||||
|
encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value),
|
||||||
|
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
|
||||||
|
options.path ? '; path=' + options.path : '',
|
||||||
|
options.domain ? '; domain=' + options.domain : '',
|
||||||
|
options.secure ? '; secure' : ''
|
||||||
|
].join(''));
|
||||||
|
}
|
||||||
|
|
||||||
|
// read
|
||||||
|
var decode = config.raw ? raw : decoded;
|
||||||
|
var cookies = document.cookie.split('; ');
|
||||||
|
var result = key ? null : {};
|
||||||
|
for (var i = 0, l = cookies.length; i < l; i++) {
|
||||||
|
var parts = cookies[i].split('=');
|
||||||
|
var name = decode(parts.shift());
|
||||||
|
var cookie = decode(parts.join('='));
|
||||||
|
|
||||||
|
if (key && key === name) {
|
||||||
|
result = fromJSON(cookie);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!key) {
|
||||||
|
result[name] = fromJSON(cookie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
config.defaults = {};
|
||||||
|
|
||||||
|
$.removeCookie = function (key, options) {
|
||||||
|
if ($.cookie(key) !== null) {
|
||||||
|
$.cookie(key, null, options);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
})(jQuery, document);
|
Loading…
Add table
Reference in a new issue