Signed-off-by: Nathan Hsieh <hsieh.nathan@gmail.com> Upstream-commit: 6a874cf711a7df5e60f1290e02fe4ca25851b985 Component: engine
6.8 KiB
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
#Dockerfile Tutorial
Test your Dockerfile knowledge - Level 2
Questions:
FROMWhich Dockerfile instruction sets the default command for your image?
ENTRYPOINT or CMDWhat is the character used to add comments in Dockerfiles?
#Which Dockerfile instruction sets the username to use when running the image?
USERWhat is the Dockerfile instruction to execute any command on the current image and commit the results?
RUNWhich Dockerfile instruction sets ports to be exposed when running the image?
EXPOSEWhat is the Dockerfile instruction to specify the maintainer of the Dockerfile?
MAINTAINERWhich Dockerfile instruction lets you trigger a command as soon as the container starts?
ENTRYPOINT or CMD
<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>
Fill the Dockerfile
Your best friend Roberto Hashioka sent you a Dockerfile, but some parts were lost in the ocean. Can you find the missing parts?
# Redis # # VERSION 0.42 # # use the ubuntu base image provided by dotCloud ub
MAINT Ro Ha roberto.hashioka@dotcloud.com
# make sure the package repository is up to date echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list apt-get update
# install wget (required for redis installation) apt-get install -y wget
# install make (required for redis installation) apt-get install -y make
# install gcc (required for redis installation) RUN apt-get install -y
# install apache2 wget http://download.redis.io/redis-stable.tar.gz tar xvzf redis-stable.tar.gz cd redis-stable && make && make install
# launch redis when starting the image ["redis-server"]
# run as user dameon daemon
# expose port 6379 6379
Tell the world! Tweet
Check the Dockerfile
What's next?
Thanks for going through our tutorial! We will be posting Level 3 shortly. Follow us on twitter
Follow @docker
<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>
In the meantime, check out this blog post by Michael Crosby that describes Dockerfile Best Practices.
Back to the Docs!