mirror of
https://github.com/docker/docs.git
synced 2026-03-27 22:38:54 +07:00
925 lines
40 KiB
XML
925 lines
40 KiB
XML
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
|
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
|
<channel>
|
|
<title>Linuxes on Docker Docs</title>
|
|
<link>http://localhost/linux/</link>
|
|
<description>Recent content in Linuxes on Docker Docs</description>
|
|
<generator>Hugo -- gohugo.io</generator>
|
|
<language>en-us</language>
|
|
<atom:link href="http://localhost/linux/index.xml" rel="self" type="application/rss+xml" />
|
|
|
|
<item>
|
|
<title>Build your own image</title>
|
|
<link>http://localhost/linux/step_four/</link>
|
|
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
|
|
|
<guid>http://localhost/linux/step_four/</guid>
|
|
<description>
|
|
|
|
<h1 id="build-your-own-image">Build your own image</h1>
|
|
|
|
<p>The <code>whalesay</code> image could be improved. It would be nice if you didn&rsquo;t have to
|
|
think of something to say. And you type a lot to get <code>whalesay</code> to talk.</p>
|
|
|
|
<pre><code>docker run docker/whalesay cowsay boo-boo
|
|
</code></pre>
|
|
|
|
<p>In this next section, you will improve the <code>whalesay</code> image by building a new version that &ldquo;talks on its own&rdquo; and requires fewer words to run.</p>
|
|
|
|
<h2 id="step-1-write-a-dockerfile">Step 1: Write a Dockerfile</h2>
|
|
|
|
<p>In this step, you use your favorite text editor to write a short Dockerfile. A
|
|
Dockerfile describes the software that is &ldquo;baked&rdquo; into an image. It isn&rsquo;t just
|
|
ingredients tho, it can tell the software what environment to use or what
|
|
commands to run. Your recipe is going to be very short.</p>
|
|
|
|
<ol>
|
|
<li><p>Go back to your terminal window.</p></li>
|
|
|
|
<li><p>Make a new directory by typing <code>mkdir mydockerbuild</code> and pressing RETURN.</p>
|
|
|
|
<pre><code>$ mkdir mydockerbuild
|
|
</code></pre>
|
|
|
|
<p>This directory serves as the &ldquo;context&rdquo; for your build. The context just means it contains all the things you need to build your image.</p></li>
|
|
|
|
<li><p>Change to your new directory.</p>
|
|
|
|
<pre><code>$ cd mydockerbuild
|
|
</code></pre>
|
|
|
|
<p>Right now the directory is empty.</p></li>
|
|
|
|
<li><p>Create a text file called <code>Dockerfile</code> in your current directory.</p>
|
|
|
|
<p>You can use any text editor for example, <code>vi</code> or <code>nano</code> to do this.</p></li>
|
|
|
|
<li><p>Open your Dockerfile file.</p></li>
|
|
|
|
<li><p>Add a line to the file like this:</p>
|
|
|
|
<pre><code>FROM docker/whalesay:latest
|
|
</code></pre>
|
|
|
|
<p>The <code>FROM</code> keyword tells Docker which image your image is based on. Whalesay is
|
|
cute and has the <code>cowsay</code> program already, so we&rsquo;ll start there.</p></li>
|
|
|
|
<li><p>Now, add the <code>fortunes</code> program to the image.</p>
|
|
|
|
<pre><code>RUN apt-get -y update &amp;&amp; apt-get install -y fortunes
|
|
</code></pre>
|
|
|
|
<p>The <code>fortunes</code> program has a command that prints out wise sayings for our
|
|
whale to say. So, the first step is to install it. This line installs the
|
|
software into the image.</p></li>
|
|
|
|
<li><p>Once the image has the software it needs, you instruct the software to run
|
|
when the image is loaded.</p>
|
|
|
|
<pre><code>CMD /usr/games/fortune -a | cowsay
|
|
</code></pre>
|
|
|
|
<p>This line tells the <code>fortune</code> program to pass a nifty quote to the <code>cowsay</code> program.</p></li>
|
|
|
|
<li><p>Check your work, your file should look like this:</p>
|
|
|
|
<pre><code>FROM docker/whalesay:latest
|
|
RUN apt-get -y update &amp;&amp; apt-get install -y fortunes
|
|
CMD /usr/games/fortune -a | cowsay
|
|
</code></pre></li>
|
|
|
|
<li><p>Save and close your Dockerfile.</p>
|
|
|
|
<p>At this point, you have all your software ingredients and behaviors described in a Dockerfile. You are ready to build a new image.</p></li>
|
|
</ol>
|
|
|
|
<h2 id="step-2-build-an-image-from-your-dockerfile">Step 2: Build an image from your Dockerfile</h2>
|
|
|
|
<ol>
|
|
<li><p>Now, build your new image by typing the <code>docker build -t docker-whale .</code> command in your terminal (don&rsquo;t forget the . period).</p>
|
|
|
|
<pre><code>$ docker build -t docker-whale .
|
|
Sending build context to Docker daemon 158.8 MB
|
|
...snip...
|
|
Removing intermediate container a8e6faa88df3
|
|
Successfully built 7d9495d03763
|
|
</code></pre>
|
|
|
|
<p>The command takes several seconds to run and reports its outcome. Before
|
|
you do anything with the new image, take a minute to learn about the
|
|
Dockerfile build process.</p></li>
|
|
</ol>
|
|
|
|
<h2 id="step-3-learn-about-the-build-process">Step 3: Learn about the build process</h2>
|
|
|
|
<p>The <code>docker build -t docker-whale .</code> command takes the <code>Dockerfile</code> in the
|
|
current directory, and builds an image called <code>docker-whale</code> on your local
|
|
machine. The command takes about a minute and its output looks really long and
|
|
complex. In this section, you learn what each message means.</p>
|
|
|
|
<p>First Docker checks to make sure it has everything it needs to build.</p>
|
|
|
|
<pre><code>Sending build context to Docker daemon 158.8 MB
|
|
</code></pre>
|
|
|
|
<p>Then, Docker loads with the <code>whalesay</code> image. It already has this image
|
|
locally as your might recall from the last page. So, Docker doesn&rsquo;t need to
|
|
download it.</p>
|
|
|
|
<pre><code>Step 0 : FROM docker/whalesay:latest
|
|
---&gt; fb434121fc77
|
|
</code></pre>
|
|
|
|
<p>Docker moves onto the next step which is to update the <code>apt-get</code> package
|
|
manager. This takes a lot of lines, no need to list them all again here.</p>
|
|
|
|
<pre><code>Step 1 : RUN apt-get -y update &amp;&amp; apt-get install -y fortunes
|
|
---&gt; Running in 27d224dfa5b2
|
|
Ign http://archive.ubuntu.com trusty InRelease
|
|
Ign http://archive.ubuntu.com trusty-updates InRelease
|
|
Ign http://archive.ubuntu.com trusty-security InRelease
|
|
Hit http://archive.ubuntu.com trusty Release.gpg
|
|
....snip...
|
|
Get:15 http://archive.ubuntu.com trusty-security/restricted amd64 Packages [14.8 kB]
|
|
Get:16 http://archive.ubuntu.com trusty-security/universe amd64 Packages [134 kB]
|
|
Reading package lists...
|
|
---&gt; eb06e47a01d2
|
|
</code></pre>
|
|
|
|
<p>Then, Docker installs the new <code>fortunes</code> software.</p>
|
|
|
|
<pre><code>Removing intermediate container e2a84b5f390f
|
|
Step 2 : RUN apt-get install -y fortunes
|
|
---&gt; Running in 23aa52c1897c
|
|
Reading package lists...
|
|
Building dependency tree...
|
|
Reading state information...
|
|
The following extra packages will be installed:
|
|
fortune-mod fortunes-min librecode0
|
|
Suggested packages:
|
|
x11-utils bsdmainutils
|
|
The following NEW packages will be installed:
|
|
fortune-mod fortunes fortunes-min librecode0
|
|
0 upgraded, 4 newly installed, 0 to remove and 3 not upgraded.
|
|
Need to get 1961 kB of archives.
|
|
After this operation, 4817 kB of additional disk space will be used.
|
|
Get:1 http://archive.ubuntu.com/ubuntu/ trusty/main librecode0 amd64 3.6-21 [771 kB]
|
|
...snip......
|
|
Setting up fortunes (1:1.99.1-7) ...
|
|
Processing triggers for libc-bin (2.19-0ubuntu6.6) ...
|
|
---&gt; c81071adeeb5
|
|
Removing intermediate container 23aa52c1897c
|
|
</code></pre>
|
|
|
|
<p>Finally, Docker finishes the build and reports its outcome.</p>
|
|
|
|
<pre><code>Step 3 : CMD /usr/games/fortune -a | cowsay
|
|
---&gt; Running in a8e6faa88df3
|
|
---&gt; 7d9495d03763
|
|
Removing intermediate container a8e6faa88df3
|
|
Successfully built 7d9495d03763
|
|
</code></pre>
|
|
|
|
<h2 id="step-4-run-your-new-docker-whale">Step 4: Run your new docker-whale</h2>
|
|
|
|
<p>In this step, you verify the new images is on your computer and then you run your new image.</p>
|
|
|
|
<ol>
|
|
<li><p>If it isn&rsquo;t already there, place your cursor at the prompt in your terminal window.</p></li>
|
|
|
|
<li><p>Type <code>docker images</code> and press RETURN.</p>
|
|
|
|
<p>This command, you might remember, lists the images you have locally.</p>
|
|
|
|
<pre><code>$ docker images
|
|
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
|
|
docker-whale latest 7d9495d03763 4 minutes ago 273.7 MB
|
|
docker/whalesay latest fb434121fc77 4 hours ago 247 MB
|
|
hello-world latest 91c95931e552 5 weeks ago 910 B
|
|
</code></pre></li>
|
|
|
|
<li><p>Run your new image by typing <code>docker run docker-whale</code> and pressing RETURN.</p>
|
|
|
|
<pre><code>$ docker run docker-whale
|
|
_________________________________________
|
|
/ &quot;He was a modest, good-humored boy. It \
|
|
\ was Oxford that made him insufferable.&quot; /
|
|
-----------------------------------------
|
|
\
|
|
\
|
|
\
|
|
## .
|
|
## ## ## ==
|
|
## ## ## ## ===
|
|
/&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;___/ ===
|
|
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
|
|
\______ o __/
|
|
\ \ __/
|
|
\____\______/
|
|
</code></pre></li>
|
|
</ol>
|
|
|
|
<p>As you can see, you&rsquo;ve made the whale a lot smarter. It finds its own
|
|
things to say and the command line is a lot shorter! You may also notice
|
|
that Docker didn&rsquo;t have to download anything. That is because the image was
|
|
built locally and is already available.</p>
|
|
|
|
<h2 id="where-to-go-next">Where to go next</h2>
|
|
|
|
<p>On this page, you learned to build an image by writing your own Dockerfile.
|
|
You ran your image in a container. In the next section, you take the first step in sharing your image by
|
|
<a href="../linux/step_five/">creating a Docker Hub account</a>.</p>
|
|
|
|
<p>&nbsp;</p>
|
|
</description>
|
|
</item>
|
|
|
|
<item>
|
|
<title>Create a Docker Hub account and repository </title>
|
|
<link>http://localhost/linux/step_five/</link>
|
|
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
|
|
|
<guid>http://localhost/linux/step_five/</guid>
|
|
<description>
|
|
|
|
<h1 id="create-a-docker-hub-account-repository">Create a Docker Hub account &amp; repository</h1>
|
|
|
|
<p>You&rsquo;ve built something really cool, you should share it. In this next section,
|
|
you&rsquo;ll do just that. You&rsquo;ll need a Docker Hub account. Then, you&rsquo;ll push your
|
|
image up to it so other people with Docker can run it.</p>
|
|
|
|
<h2 id="step-1-sign-up-for-an-account">Step 1: Sign up for an account</h2>
|
|
|
|
<ol>
|
|
<li><p>Use your browser to navigate to <a href="https://hub.docker.com/?utm_source=getting_started_guide&utm_medium=embedded_Linux&utm_campaign=create_docker_hub_account" target="_blank">the Docker Hub signup page</a>.</p>
|
|
|
|
<p>Your browser displays the page.</p>
|
|
|
|
|
|
<figure >
|
|
|
|
<img src="../tutimg/hub_signup.png" />
|
|
|
|
|
|
</figure>
|
|
</li>
|
|
|
|
<li><p>Fill out the form on the signup page.</p>
|
|
|
|
<p>Docker Hub is free. Docker does need a name, password, and email address.</p></li>
|
|
|
|
<li><p>Press <strong>Signup</strong>.</p>
|
|
|
|
<p>The browser displays the welcome to Docker Hub page.</p></li>
|
|
</ol>
|
|
|
|
<h2 id="step-2-verify-your-email-and-add-a-repository">Step 2: Verify your email and add a repository</h2>
|
|
|
|
<p>Before you can share anything on the hub, you need to verify your email address.</p>
|
|
|
|
<ol>
|
|
<li><p>Open your email inbox.</p></li>
|
|
|
|
<li><p>Look for the email titled <code>Please confirm email for your Docker Hub account</code>.</p>
|
|
|
|
<p>If you don&rsquo;t see the email, check your Spam folder or wait a moment for the
|
|
email to arrive.</p></li>
|
|
|
|
<li><p>Open the email and click the <strong>Confirm Your Email</strong> button.</p>
|
|
|
|
<p>The browser opens Docker Hub to your profile page.</p></li>
|
|
|
|
<li><p>Choose <strong>Create Repository</strong>.</p>
|
|
|
|
<p>The browser opens the <strong>Create Repository</strong> page.</p></li>
|
|
|
|
<li><p>Provide a Repository Name and Short Description.</p></li>
|
|
|
|
<li><p>Make sure Visibility is set to <strong>Public</strong>.</p>
|
|
|
|
<p>When you are done, your form should look similar to the following:</p>
|
|
|
|
|
|
<figure >
|
|
|
|
<img src="../tutimg/add_repository.png" />
|
|
|
|
|
|
</figure>
|
|
</li>
|
|
|
|
<li><p>Press <strong>Create</strong> when you are done.</p>
|
|
|
|
<p>Docker Hub creates your new repository.</p></li>
|
|
</ol>
|
|
|
|
<h2 id="where-to-go-next">Where to go next</h2>
|
|
|
|
<p>On this page, you opened an account on Docker Hub and created a new repository.
|
|
In the next section, you populate the repository <a href="../linux/step_six/">by tagging and pushing the
|
|
image you created earlier</a>.</p>
|
|
|
|
<p>&nbsp;</p>
|
|
</description>
|
|
</item>
|
|
|
|
<item>
|
|
<title>Find & run the whalesay image </title>
|
|
<link>http://localhost/linux/step_three/</link>
|
|
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
|
|
|
<guid>http://localhost/linux/step_three/</guid>
|
|
<description>
|
|
|
|
<h1 id="find-and-run-the-whalesay-image">Find and run the whalesay image</h1>
|
|
|
|
<p>People all over the world create Docker images. You can find these images by browsing the Docker Hub. In this next section, you&rsquo;ll do just that to find the image to use in the rest of this getting started.</p>
|
|
|
|
<h2 id="step-1-locate-the-whalesay-image">Step 1: Locate the whalesay image</h2>
|
|
|
|
<ol>
|
|
<li><p>Open your browser and <a href="https://hub.docker.com/?utm_source=getting_started_guide&utm_medium=embedded_Linux&utm_campaign=find_whalesay" target=_blank> browse to the Docker Hub</a>.</p>
|
|
|
|
|
|
<figure >
|
|
|
|
<img src="../tutimg/browse_and_search.png" />
|
|
|
|
|
|
</figure>
|
|
|
|
|
|
<p>The Docker Hub contains images from individuals like you and official images
|
|
from organizations like RedHat, IBM, Google, and a whole lot more.</p></li>
|
|
|
|
<li><p>Click <strong>Browse &amp; Search</strong>.</p>
|
|
|
|
<p>The browser opens the search page.</p></li>
|
|
|
|
<li><p>Enter the word <code>whalesay</code> in the search bar.</p>
|
|
|
|
|
|
<figure >
|
|
|
|
<img src="../tutimg/image_found.png" />
|
|
|
|
|
|
</figure>
|
|
</li>
|
|
|
|
<li><p>Click on the <strong>docker/whalesay</strong> image in the results.</p>
|
|
|
|
<p>The browser displays the repository for the <strong>whalesay</strong> image.</p>
|
|
|
|
|
|
<figure >
|
|
|
|
<img src="../tutimg/whale_repo.png" />
|
|
|
|
|
|
</figure>
|
|
|
|
|
|
<p>Each image repository contains information about an image. It should
|
|
include information such as what kind of software the image contains and
|
|
how to use it. You may notice that the <strong>whalesay</strong> image is based on a
|
|
Linux distribution called Ubuntu. In the next step, you run the <strong>whalesay</strong> image on your machine.</p></li>
|
|
</ol>
|
|
|
|
<h2 id="step-2-run-the-whalesay-image">Step 2: Run the whalesay image</h2>
|
|
|
|
<ol>
|
|
<li><p>Put your cursor in your terminal window at the <code>$</code> prompt.</p></li>
|
|
|
|
<li><p>Type the <code>docker run docker/whalesay cowsay boo</code> command and press RETURN.</p>
|
|
|
|
<p>This command runs the <strong>whalesay</strong> image in a container. Your terminal should look like the following:</p>
|
|
|
|
<pre><code>$ docker run docker/whalesay cowsay boo
|
|
Unable to find image 'docker/whalesay:latest' locally
|
|
latest: Pulling from docker/whalesay
|
|
e9e06b06e14c: Pull complete
|
|
a82efea989f9: Pull complete
|
|
37bea4ee0c81: Pull complete
|
|
07f8e8c5e660: Pull complete
|
|
676c4a1897e6: Pull complete
|
|
5b74edbcaa5b: Pull complete
|
|
1722f41ddcb5: Pull complete
|
|
99da72cfe067: Pull complete
|
|
5d5bd9951e26: Pull complete
|
|
fb434121fc77: Already exists
|
|
Digest: sha256:d6ee73f978a366cf97974115abe9c4099ed59c6f75c23d03c64446bb9cd49163
|
|
Status: Downloaded newer image for docker/whalesay:latest
|
|
_____
|
|
&lt; boo &gt;
|
|
-----
|
|
\
|
|
\
|
|
\
|
|
## .
|
|
## ## ## ==
|
|
## ## ## ## ===
|
|
/&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;___/ ===
|
|
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
|
|
\______ o __/
|
|
\ \ __/
|
|
\____\______/
|
|
|
|
|
|
The first time you run a software image, the `docker` command looks for it
|
|
on your local system. If the image isn't there, then `docker` gets it from
|
|
the hub.
|
|
</code></pre></li>
|
|
|
|
<li><p>While still in the terminal, type <code>docker images</code> command and press RETURN.</p>
|
|
|
|
<p>The command lists all the images on your local system. You should see
|
|
<code>docker/whalesay</code> in the list.</p>
|
|
|
|
<pre><code>$ docker images
|
|
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
|
|
docker/whalesay latest fb434121fc77 3 hours ago 247 MB
|
|
hello-world latest 91c95931e552 5 weeks ago 910 B
|
|
</code></pre>
|
|
|
|
<p>When you run an image in a container, Docker downloads the image to your
|
|
computer. This local copy of the image saves you time. Docker only
|
|
downloads the image again if the image&rsquo;s source changes on the hub. You
|
|
can, of course, delete the image yourself. You&rsquo;ll learn more about that
|
|
later. Let&rsquo;s leave the image there for now because we are going to use it
|
|
later.</p></li>
|
|
|
|
<li><p>Take a moment to play with the <strong>whalesay</strong> container a bit.</p>
|
|
|
|
<p>Try running the <code>whalesay</code> image again with a word or phrase. Try a long or
|
|
short phrase. Can you break the cow?</p>
|
|
|
|
<pre><code>$ docker run docker/whalesay cowsay boo-boo
|
|
_________
|
|
&lt; boo-boo &gt;
|
|
---------
|
|
\
|
|
\
|
|
\
|
|
## .
|
|
## ## ## ==
|
|
## ## ## ## ===
|
|
/&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;___/ ===
|
|
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
|
|
\______ o __/
|
|
\ \ __/
|
|
\____\______/
|
|
</code></pre></li>
|
|
</ol>
|
|
|
|
<h2 id="where-to-go-next">Where to go next</h2>
|
|
|
|
<p>On this page, you learned to search for images on Docker Hub. You used your
|
|
command line to run an image. You learned that running an image copies
|
|
it on your computer. Now, you are ready to create your own image with Docker.
|
|
Go on to the next part <a href="../linux/step_four/">to build your own image</a>.</p>
|
|
|
|
<p>&nbsp;</p>
|
|
</description>
|
|
</item>
|
|
|
|
<item>
|
|
<title>Get Started with Docker</title>
|
|
<link>http://localhost/linux/started/</link>
|
|
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
|
|
|
<guid>http://localhost/linux/started/</guid>
|
|
<description>
|
|
|
|
<h1 id="get-started-with-docker-for-linux">Get Started with Docker for Linux</h1>
|
|
|
|
<h4 id="this-is-written-for-users-of-linux-distribution-such-as-ubuntu-if-you-are-not-using-linux-see-the-windows-windows-started-md-or-mac-os-x-mac-started-md-version"><strong>This is written for users of Linux distribution such as Ubuntu. If you are not using Linux, see the <a href="../windows/started/">Windows</a> or <a href="../mac/started/">Mac OS X</a> version.</strong></h4>
|
|
|
|
<p>This getting started is for non-technical users who are interested in learning about Docker. By following this getting started, you&rsquo;ll learn fundamental Docker features by performing some simple tasks. You&rsquo;ll learn how to:</p>
|
|
|
|
<ul>
|
|
<li>install Docker</li>
|
|
<li>run a software image in a container</li>
|
|
<li>browse for an image on Docker Hub</li>
|
|
<li>create your own image and run it in a container</li>
|
|
<li>create a Docker Hub account and an image repository</li>
|
|
<li>create an image of your own</li>
|
|
<li>push your image to Docker Hub for others to use</li>
|
|
</ul>
|
|
|
|
<p>The getting started was user tested to reduce the chance of users having problems. For the best chance of success, follow the steps as written the first time before exploring on your own. It takes approximately 45 minutes to complete.</p>
|
|
|
|
<h3 id="make-sure-you-understand">Make sure you understand&hellip;</h3>
|
|
|
|
<p>This getting started uses Docker commands with a terminal window. You don&rsquo;t need
|
|
to be experienced using a command line, but you should be familiar with how to
|
|
open one and type commands.</p>
|
|
|
|
<p>Go to <a href="../linux/step_one/">the next page to install</a>.</p>
|
|
|
|
<p>&nbsp;</p>
|
|
</description>
|
|
</item>
|
|
|
|
<item>
|
|
<title>Install Docker</title>
|
|
<link>http://localhost/linux/step_one/</link>
|
|
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
|
|
|
<guid>http://localhost/linux/step_one/</guid>
|
|
<description>
|
|
|
|
<h1 id="install-docker">Install Docker</h1>
|
|
|
|
<ol>
|
|
<li><p>Log into your Ubuntu installation as a user with <code>sudo</code> privileges.</p></li>
|
|
|
|
<li><p>Verify that you have <code>wget</code> installed.</p>
|
|
|
|
<pre><code>$ which wget
|
|
</code></pre>
|
|
|
|
<p>If <code>wget</code> isn&rsquo;t installed, install it after updating your manager:</p>
|
|
|
|
<pre><code>$ sudo apt-get update
|
|
$ sudo apt-get install wget
|
|
</code></pre></li>
|
|
|
|
<li><p>Get the latest Docker package.</p>
|
|
|
|
<pre><code>$ wget -qO- https://get.docker.com/ | sh
|
|
</code></pre>
|
|
|
|
<p>The system prompts you for your <code>sudo</code> password. Then, it downloads and
|
|
installs Docker and its dependencies.</p>
|
|
|
|
<blockquote>
|
|
<p><strong>Note</strong>: If your company is behind a filtering proxy, you may find that the
|
|
<code>apt-key</code>
|
|
command fails for the Docker repo during installation. To work around this,
|
|
add the key directly using the following:</p>
|
|
|
|
<pre><code> $ wget -qO- https://get.docker.com/gpg | sudo apt-key add -
|
|
</code></pre>
|
|
</blockquote></li>
|
|
|
|
<li><p>Verify <code>docker</code> is installed correctly.</p>
|
|
|
|
<pre><code>$ docker run hello-world
|
|
Unable to find image 'hello-world:latest' locally
|
|
latest: Pulling from library/hello-world
|
|
535020c3e8ad: Pull complete
|
|
af340544ed62: Pull complete
|
|
Digest: sha256:a68868bfe696c00866942e8f5ca39e3e31b79c1e50feaee4ce5e28df2f051d5c
|
|
Status: Downloaded newer image for hello-world:latest
|
|
|
|
|
|
Hello from Docker.
|
|
This message shows that your installation appears to be working correctly.
|
|
|
|
|
|
To generate this message, Docker took the following steps:
|
|
1. The Docker client contacted the Docker daemon.
|
|
2. The Docker daemon pulled the &quot;hello-world&quot; image from the Docker Hub.
|
|
3. The Docker daemon created a new container from that image which runs the
|
|
executable that produces the output you are currently reading.
|
|
4. The Docker daemon streamed that output to the Docker client, which sent it
|
|
to your terminal.
|
|
|
|
|
|
To try something more ambitious, you can run an Ubuntu container with:
|
|
$ docker run -it ubuntu bash
|
|
|
|
|
|
Share images, automate workflows, and more with a free Docker Hub account:
|
|
https://hub.docker.com
|
|
|
|
|
|
For more examples and ideas, visit:
|
|
https://docs.docker.com/userguide/
|
|
|
|
|
|
To try something more ambitious, you can run an Ubuntu container with:
|
|
$ docker run -it ubuntu bash
|
|
|
|
|
|
For more examples and ideas, visit:
|
|
https://docs.docker.com/userguide/
|
|
</code></pre></li>
|
|
</ol>
|
|
|
|
<h2 id="where-to-go-next">Where to go next</h2>
|
|
|
|
<p>At this point, you have successfully installed Docker. Leave the terminal
|
|
window open. Now, go to the next page to <a href="../linux/step_two/">read a very short introduction Docker
|
|
images and containers</a>.</p>
|
|
|
|
<p>&nbsp;</p>
|
|
</description>
|
|
</item>
|
|
|
|
<item>
|
|
<title>Learning More</title>
|
|
<link>http://localhost/linux/last_page/</link>
|
|
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
|
|
|
<guid>http://localhost/linux/last_page/</guid>
|
|
<description>
|
|
|
|
<h1 id="learning-more">Learning more</h1>
|
|
|
|
<p>Depending on your interest, the Docker documentation contains a wealth of information. Here are some places that might interest you:</p>
|
|
|
|
<p><style type="text/css">
|
|
</style>
|
|
<table class="tutorial">
|
|
<tr>
|
|
<th class="tg-031e">If you are looking for</th>
|
|
<th class="tg-031e">Where to find it</th>
|
|
</tr>
|
|
<tr>
|
|
<td class="tg-031e">Information about the Docker product line.</td>
|
|
<td class="tg-031e"><a href="http://www.docker.com/products">The product explainer is a good place to start.</a></td>
|
|
</tr></p>
|
|
|
|
<p><tr>
|
|
<td class="tg-031e">Set up an automated build on Docker Hub.</td>
|
|
<td class="tg-031e"><a href="https://docs.docker.com/docker-hub/">The Docker Hub documentation.</a></td>
|
|
</tr>
|
|
</table></p>
|
|
|
|
<p>&nbsp;</p>
|
|
</description>
|
|
</item>
|
|
|
|
<item>
|
|
<title>Tag & push your image</title>
|
|
<link>http://localhost/linux/step_six/</link>
|
|
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
|
|
|
<guid>http://localhost/linux/step_six/</guid>
|
|
<description>
|
|
|
|
<h1 id="tag-push-and-pull-your-image">Tag, push, and pull your image</h1>
|
|
|
|
<p>In this section, you tag and push your <code>docker-whale</code> image to your newly
|
|
created repository. When you are done, you test the repository by pulling your
|
|
new image.</p>
|
|
|
|
<h2 id="step-1-tag-and-push-the-image">Step 1: Tag and push the image</h2>
|
|
|
|
<ol>
|
|
<li><p>Go back to your terminal.</p></li>
|
|
|
|
<li><p>List the images you currently have:</p>
|
|
|
|
<pre><code>$ docker images
|
|
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
|
|
docker-whale latest 7d9495d03763 38 minutes ago 273.7 MB
|
|
&lt;none&gt; &lt;none&gt; 5dac217f722c 45 minutes ago 273.7 MB
|
|
docker/whalesay latest fb434121fc77 4 hours ago 247 MB
|
|
hello-world latest 91c95931e552 5 weeks ago 910 B
|
|
</code></pre></li>
|
|
|
|
<li><p>Find the <code>IMAGE ID</code> for your <code>docker-whale</code> image.</p>
|
|
|
|
<pre><code>In this example, the id is `7d9495d03763`.
|
|
|
|
|
|
You'll notice that currently, the `REPOSITORY` shows the repository but not
|
|
the namespace for `docker-whale`. You need to include the `namespace` for
|
|
Docker Hub to associate it with your account. The `namespace` is the same as
|
|
your account name.
|
|
</code></pre></li>
|
|
|
|
<li><p>Use <code>IMAGE ID</code> and the <code>docker tag</code> command to tag your <code>docker-whale</code> image.</p>
|
|
|
|
<p>The command you type looks like this:</p>
|
|
|
|
|
|
<figure >
|
|
|
|
<img src="../tutimg/tagger.png" />
|
|
|
|
|
|
</figure>
|
|
|
|
|
|
<p>Of course, your account name will be your own. So, you type the command with
|
|
your image&rsquo;s ID and your account name and press RETURN.</p>
|
|
|
|
<pre><code>$ docker tag 7d9495d03763 maryatdocker/docker-whale:latest
|
|
</code></pre></li>
|
|
|
|
<li><p>Type the <code>docker images</code> command again to see your newly tagged image.</p>
|
|
|
|
<pre><code>$ docker images
|
|
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
|
|
maryatdocker/docker-whale latest 7d9495d03763 5 minutes ago 273.7 MB
|
|
docker-whale latest 7d9495d03763 2 hours ago 273.7 MB
|
|
&lt;none&gt; &lt;none&gt; 5dac217f722c 5 hours ago 273.7 MB
|
|
docker/whalesay latest fb434121fc77 5 hours ago 247 MB
|
|
hello-world latest 91c95931e552 5 weeks ago 910 B
|
|
</code></pre></li>
|
|
|
|
<li><p>Use the <code>docker login</code> command to log into the Docker Hub from the command line.</p>
|
|
|
|
<p>The format for the login command is:</p>
|
|
|
|
<pre><code>docker login --username=yourhubusername --password=yourpassword --email=youremail@company.com
|
|
</code></pre>
|
|
|
|
<p>So, for example:</p>
|
|
|
|
<pre><code>$ docker login --username=maryatdocker --password=uydfiad77fad --email=mary@docker.com
|
|
WARNING: login credentials saved in C:\Users\sven\.docker\config.json
|
|
Login Succeeded
|
|
</code></pre></li>
|
|
|
|
<li><p>Type the <code>docker push</code> command to push your image to your new repository.</p>
|
|
|
|
<pre><code>$ docker push maryatdocker/docker-whale
|
|
The push refers to a repository [maryatdocker/docker-whale] (len: 1)
|
|
7d9495d03763: Image already exists
|
|
c81071adeeb5: Image successfully pushed
|
|
eb06e47a01d2: Image successfully pushed
|
|
fb434121fc77: Image successfully pushed
|
|
5d5bd9951e26: Image successfully pushed
|
|
99da72cfe067: Image successfully pushed
|
|
1722f41ddcb5: Image successfully pushed
|
|
5b74edbcaa5b: Image successfully pushed
|
|
676c4a1897e6: Image successfully pushed
|
|
07f8e8c5e660: Image successfully pushed
|
|
37bea4ee0c81: Image successfully pushed
|
|
a82efea989f9: Image successfully pushed
|
|
e9e06b06e14c: Image successfully pushed
|
|
Digest: sha256:ad89e88beb7dc73bf55d456e2c600e0a39dd6c9500d7cd8d1025626c4b985011
|
|
</code></pre></li>
|
|
|
|
<li><p>Return to your profile on Docker Hub to see your new image.</p>
|
|
|
|
|
|
<figure >
|
|
|
|
<img src="../tutimg/new_image.png" />
|
|
|
|
|
|
</figure>
|
|
</li>
|
|
</ol>
|
|
|
|
<h1 id="step-2-pull-your-new-image">Step 2: Pull your new image</h1>
|
|
|
|
<p>In this last section, you&rsquo;ll pull the image you just pushed to hub. Before you
|
|
do that though, you&rsquo;ll need to remove the original image from your local
|
|
machine. If you left the original image on your machine. Docker would not pull
|
|
from the hub &mdash; why would it? The two images are identical.</p>
|
|
|
|
<ol>
|
|
<li><p>Place your cursor at the prompt in your terminal window.</p></li>
|
|
|
|
<li><p>Type <code>docker images</code> to list the images you currently have on your local machine.</p>
|
|
|
|
<pre><code>$ docker images
|
|
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
|
|
maryatdocker/docker-whale latest 7d9495d03763 5 minutes ago 273.7 MB
|
|
docker-whale latest 7d9495d03763 2 hours ago 273.7 MB
|
|
&lt;none&gt; &lt;none&gt; 5dac217f722c 5 hours ago 273.7 MB
|
|
docker/whalesay latest fb434121fc77 5 hours ago 247 MB
|
|
hello-world latest 91c95931e552 5 weeks ago 910 B
|
|
</code></pre>
|
|
|
|
<p>To make a good test, you need to remove the <code>maryatdocker/docker-whale</code> and
|
|
<code>docker-whale</code> images from your local system. Removing them forces the next
|
|
<code>docker pull</code> to get the image from your repository.</p></li>
|
|
|
|
<li><p>Use the <code>docker rmi</code> to remove the <code>maryatdocker/docker-whale</code> and <code>docker-whale</code>
|
|
images.</p>
|
|
|
|
<p>You can use an ID or the name to remove an image.</p>
|
|
|
|
<pre><code>$ docker rmi -f 7d9495d03763
|
|
$ docker rmi -f docker-whale
|
|
</code></pre></li>
|
|
|
|
<li><p>Pull a new image from your repository using the <code>docker pull</code> command.</p>
|
|
|
|
<p>The command you type should include your username from Docker Hub.</p>
|
|
|
|
<pre><code> docker pull yourusername/docker-whale
|
|
</code></pre>
|
|
|
|
<p>Since the image is no longer available on your local system, Docker downloads it.</p>
|
|
|
|
<pre><code> $ docker run maryatdocker/docker-whale
|
|
Unable to find image 'maryatdocker/docker-whale:latest' locally
|
|
latest: Pulling from maryatdocker/docker-whale
|
|
eb06e47a01d2: Pull complete
|
|
c81071adeeb5: Pull complete
|
|
7d9495d03763: Already exists
|
|
e9e06b06e14c: Already exists
|
|
a82efea989f9: Already exists
|
|
37bea4ee0c81: Already exists
|
|
07f8e8c5e660: Already exists
|
|
676c4a1897e6: Already exists
|
|
5b74edbcaa5b: Already exists
|
|
1722f41ddcb5: Already exists
|
|
99da72cfe067: Already exists
|
|
5d5bd9951e26: Already exists
|
|
fb434121fc77: Already exists
|
|
Digest: sha256:ad89e88beb7dc73bf55d456e2c600e0a39dd6c9500d7cd8d1025626c4b985011
|
|
Status: Downloaded newer image for maryatdocker/docker-whale:latest
|
|
________________________________________
|
|
/ Having wandered helplessly into a \
|
|
| blinding snowstorm Sam was greatly |
|
|
| relieved to see a sturdy Saint Bernard |
|
|
| dog bounding toward him with the |
|
|
| traditional keg of brandy strapped to |
|
|
| his collar. |
|
|
| |
|
|
| &quot;At last,&quot; cried Sam, &quot;man's best |
|
|
\ friend -- and a great big dog, too!&quot; /
|
|
----------------------------------------
|
|
\
|
|
\
|
|
\
|
|
## .
|
|
## ## ## ==
|
|
## ## ## ## ===
|
|
/&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;&quot;___/ ===
|
|
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
|
|
\______ o __/
|
|
\ \ __/
|
|
\____\______/
|
|
</code></pre></li>
|
|
</ol>
|
|
|
|
<h2 id="where-to-go-next">Where to go next</h2>
|
|
|
|
<p>You&rsquo;ve done a lot, you&rsquo;ve done all of the following fundamental Docker tasks.</p>
|
|
|
|
<ul>
|
|
<li>installed Docker</li>
|
|
<li>run a software image in a container</li>
|
|
<li>located an interesting image on Docker Hub</li>
|
|
<li>run the image on your own machine</li>
|
|
<li>modified an image to create your own and run it</li>
|
|
<li>create a Docker Hub account and repository</li>
|
|
<li>pushed your image to Docker Hub for others to share</li>
|
|
</ul>
|
|
|
|
<p><a href="https://twitter.com/intent/tweet?button_hashtag=dockerdocs&text=Just%20ran%20a%20container%20with%20an%20image%20I%20built.%20Find%20it%20on%20%23dockerhub.%20Build%20your%20own%3A%20http%3A%2F%2Fgoo.gl%2FMUi7cA" class="twitter-hashtag-button" data-size="large" data-related="docker" target="_blank">Tweet your accomplishment!</a>
|
|
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?&lsquo;http&rsquo;:&lsquo;https&rsquo;;if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+&rsquo;://platform.twitter.com/widgets.js&rsquo;;fjs.parentNode.insertBefore(js,fjs);}}(document, &lsquo;script&rsquo;, &lsquo;twitter-wjs&rsquo;);</script></p>
|
|
|
|
<p>You&rsquo;ve only scratched the surface of what Docker can do. Go to the next page to <a href="../linux/last_page/">learn more</a>.</p>
|
|
|
|
<p>&nbsp;</p>
|
|
</description>
|
|
</item>
|
|
|
|
<item>
|
|
<title>Understand images & containers</title>
|
|
<link>http://localhost/linux/step_two/</link>
|
|
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
|
|
|
<guid>http://localhost/linux/step_two/</guid>
|
|
<description>
|
|
|
|
<h1 id="learn-about-images-containers">Learn about images &amp; containers</h1>
|
|
|
|
<p>As the last step in your installation, you ran the <code>docker run hello-world</code> command. With this one command, you completed the core tasks to using Docker. The command you ran had three parts.</p>
|
|
|
|
|
|
<figure >
|
|
|
|
<img src="../tutimg/container_explainer.png" />
|
|
|
|
|
|
</figure>
|
|
|
|
|
|
<p>A <em>container</em> is a stripped-to-basics version of a Linux operating system. An <em>image</em> is software you load into a container. When you ran the command, the Docker software:</p>
|
|
|
|
<ul>
|
|
<li>checked to see if you had the <code>hello-world</code> software image</li>
|
|
<li>downloaded the image from the Docker Hub (more about the hub later)</li>
|
|
<li>loaded the image into the container and &ldquo;ran&rdquo; it</li>
|
|
</ul>
|
|
|
|
<p>Depending on how it was built, an image might run a simple, single command and then exit. This is what <code>Hello-World</code> did.</p>
|
|
|
|
<p>A Docker image, though, is capable of much more. An image can start software as complex as a database, wait for you (or someone else) to add data, store the data for later use, and then wait for the next person.</p>
|
|
|
|
<p>Who built the <code>hello-world</code> software image though? In this case, Docker did but anyone can. Docker lets people (or companies) create and share software through Docker images. Using Docker, you don&rsquo;t have to worry about whether your computer can run the software in a Docker image &mdash; a Docker container <em>can always run it</em>.</p>
|
|
|
|
<h2 id="where-to-go-next">Where to go next</h2>
|
|
|
|
<p>See, that was quick wasn&rsquo;t it? Now, you are ready to do some really fun stuff with Docker.
|
|
Go on to the next part <a href="../linux/step_three/">to find and run the whalesay image</a>.</p>
|
|
|
|
<p>&nbsp;</p>
|
|
</description>
|
|
</item>
|
|
|
|
</channel>
|
|
</rss> |