1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/docs/sources/userguide/level2.md

97 lines
6.3 KiB
Markdown
Raw Normal View History

page_title: Docker images test
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>
2014-10-06 14:57:09 -04:00
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="dockerfile back" href="/userguide/dockerimages/#creating-our-own-images">Back</a>
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>
2014-10-06 14:57:09 -04:00
#Dockerfile tutorial
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>
2014-10-06 14:57:09 -04:00
## Test your Dockerfile knowledge - Level 2
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>
2014-10-06 14:57:09 -04:00
### 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>
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>
2014-10-06 14:57:09 -04:00
</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>
&#35; Redis
&#35;
&#35; VERSION 0.42
&#35;
&#35; 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>
&#35; 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>
&#35; install wget (required for redis installation)
<input id="run2" class="l_fill" type="text"> apt-get install -y wget<br>
&#35; install make (required for redis installation)
<input id="run3" class="l_fill" type="text"> apt-get install -y make<br>
&#35; install gcc (required for redis installation)
RUN apt-get install -y <input id="gcc" class="l_fill" type="text"><br>
&#35; 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>
&#35; launch redis when starting the image
<input id="entrypoint" class="l_fill" type="text"> ["redis-server"]<br>
&#35; run as user dameon
<input id="user" class="l_fill" type="text"> daemon<br>
&#35; 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 in the future.
To improve your Dockerfile writing skills even further, visit the <a href="https://docs.docker.com/articles/dockerfile_best-practices/">Dockerfile best practices page</a>.
<a title="creating our own images" class="btn btn-primary" href="/userguide/dockerimages/#creating-our-own-images">Back to the Docs!</a>