Add learning center walkthroughs (#16893)

* add learning center walkthroughs
This commit is contained in:
Craig Osterhout 2023-03-26 20:43:19 -07:00 committed by GitHub
parent ae70911af0
commit f4258c0c1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 407 additions and 0 deletions

View File

@ -49,6 +49,18 @@ guides:
path: /get-started/09_image_best/
- title: "Part 10: What next?"
path: /get-started/11_what_next/
- sectiontitle: Docker Desktop hands-on guides
section:
- path: /get-started/hands-on-overview/
title: Overview
- path: /get-started/what-is-a-container/
title: What is a container?
- path: /get-started/run-your-own-container/
title: Run your own container
- path: /get-started/run-docker-hub-images/
title: Run Docker Hub images
- path: /get-started/publish-your-own-image/
title: Publish your own image
- sectiontitle: Language-specific guides
section:
- path: /language/

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
viewBox="0 0 384 512"
version="1.1"
id="svg4"
sodipodi:docname="arrow-up.svg"
inkscape:version="1.2.2 (732a01da63, 2022-12-09)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs8" />
<sodipodi:namedview
id="namedview6"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
showgrid="false"
inkscape:zoom="1.6191406"
inkscape:cx="93.568154"
inkscape:cy="256.30881"
inkscape:window-width="1920"
inkscape:window-height="1009"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="svg4" />
<!--! Font Awesome Free 6.3.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. -->
<path
d="M214.6 41.4c-12.5-12.5-32.8-12.5-45.3 0l-160 160c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L160 141.2V448c0 17.7 14.3 32 32 32s32-14.3 32-32V141.2L329.4 246.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-160-160z"
id="path2"
style="fill:#666666;stroke:#677285;stroke-opacity:1" />
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -0,0 +1,48 @@
---
title: Docker Desktop hands-on guides
keywords: get started, setup, orientation, quickstart, intro, concepts
description: Overview of Docker Desktop hands-on guides
---
Use the resources in this section to learn Docker concepts by using Docker Desktop.
<div class="component-container">
<!--start row-->
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-4 block">
<div class="component">
<div class="component-icon">
<a href="/get-started/what-is-a-container/"><img src="/assets/images/help.svg" alt="what is a container" width="70" height="70"></a>
</div>
<h2 id="what-is-a-container"><a href="/get-started/what-is-a-container/">What is a container?</a></h2>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-4 block">
<div class="component">
<div class="component-icon">
<a href="/get-started/run-your-own-container/"><img src="/assets/images/build-frontends.svg" alt="run your own container" width="70" height="70"></a>
</div>
<h2 id="run-your-own-container"><a href="/get-started/run-your-own-container">Run your own container</a></h2>
</div>
</div>
</div>
<!--start row-->
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-4 block">
<div class="component">
<div class="component-icon">
<a href="/get-started/run-docker-hub-images/"><img src="/assets/images/build-multi-platform.svg" alt="run docker hub images" width="70" height="70"></a>
</div>
<h2 id="run-docker-hub-images"><a href="/get-started/run-docker-hub-images">Run Docker Hub images</a></h2>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-4 block">
<div class="component">
<div class="component-icon">
<a href="/get-started/publish-your-own-image/"><img src="/assets/images/arrow-up.svg" alt="publish your own image" width="70" height="70"></a>
</div>
<h2 id="publish-your-own-image"><a href="/get-started/publish-your-own-image/">Publish your own image</a></h2>
</div>
</div>
</div>
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 407 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 930 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -0,0 +1,49 @@
---
title: Publish your own image
keywords: get started, quick start, intro, concepts
description: Learn how to publish your own images
---
Follow this guide to learn how you can share your packaged application in an image using Docker Hub.
## Step 1: Get an image
Before you publish your image, you need an image to publish. For this guide, use the `welcome-to-docker` image.
To get the image, use Docker Desktop to search for the `welcome-to-docker` image, and then select **Pull**.
![Pulling the welcome-to-docker image](images/getting-started-pull.gif){:width="500px"}
## Step 2: Sign in to Docker
To publish images publicly on Docker Hub, you first need an account. Select **Sign in** on the top-right of Docker Desktop to either sign in or create a new account on Docker Hub.
![Signing in to Docker](images/getting-started-sign-in.png)
## Step 3: Rename your image
Before you can publish your image to Docker Hub, you need to rename it so that Docker Hub knows that the image is yours. Run the following `docker tag` command in your terminal to rename your image. Replace `YOUR-USERNAME` with your Docker ID.
```console
$ docker tag docker/welcome-to-docker YOUR-USERNAME/welcome-to-docker
```
## Step 4: Push your image to Docker Hub
In Docker Desktop, go to the **Images** tab and find your image. In the **Actions** column, select the **Show image actions** icon and then select **Push to Hub**. Your image uploads to Docker Hub and is publicly available for anyone to use.
![Push image to Docker Hub](images/getting-started-push.gif)
## Step 5: Verify the image is on Docker Hub
That's it! Your image is now shared on Docker Hub. In your browser, go to [Docker Hub](https://hub.docker.com){:target="_blank" rel="noopener" class="_"} and verify that you see the `welcome-to-docker` repository.
## What's next
In this guide you learned how to publish your own image to Docker Hub. Continue to the following language-specific guides to learn more about creating images for applications in other languages:
- [Node.js](../language/nodejs/index.md)
- [Python](../language/python/index.md)
- [Go](../language/golang/index.md)
- [Java](../language/java/index.md)
- [C# (.NET)](../language/dotnet/index.md)

View File

@ -0,0 +1,35 @@
---
title: Run Docker Hub images
keywords: get started, quick start, intro, concepts
description: Learn how to run Docker Hub images
---
You can share and store images in Docker Hub ([http://hub.docker.com](http://hub.docker.com){:target="_blank" rel="noopener" class="_"}). Docker hub has over 100,000 images created by developers that you can run locally. You can search for Docker Hub images and run them directly from Docker Desktop.
## Step 1: Search for the image
You can search for Docker Hub images on Docker Desktop. Use the search bar, or use the shortcut ⌘K on Mac or Ctrl + K on Windows. In the search bar, specify `welcome-to-docker` to find the `docker/welcome-to-docker` image used in this guide.
![Search Docker Desktop for the welcome-to-docker image](images/getting-started-search.png){:width="500px"}
## Step 2: Run the image
To run the `docker/welcome-to-docker` image, select **Run**. When the **Optional settings** appear, specify the **Host port** number `8090` and then select **Run**.
![Running the image in Docker Desktop](images/getting-started-run.gif){:width="500px"}
> **Note**
>
> Many images hosted on Docker Hub have a description that highlights what settings must be set in order to run them. You can read the description for the image on Docker Hub by selecting **View on Hub** or by searching for the image directly on [https://hub.docker.com](https://hub.docker.com){:target="_blank" rel="noopener" class="_"}.
## Step 3: Explore the container
That's it! The container is ready to use. Go to the **Containers** tab in Docker Desktop to view the container.
![Viewing the Containers tab in Docker Desktop](images/getting-started-view.png){:width="500px"}
## What's next
In this guide, you ran someone else's image from Docker Hub. Continue to the next guide to learn how you can publish your own image to Docker Hub.
[Publish your own image](./publish-your-own-image.md){: .button .primary-btn}

View File

@ -0,0 +1,165 @@
---
title: Run your own container
keywords: get started, quick start, intro, concepts
description: Learn how to run a container from scratch
---
Follow this guide to learn the basic steps of running a container from scratch. This guide uses a sample Node.js application, but it's not necessary to know Node.js.
## Step 1: Get the sample application
If you have git, you can clone the repository for the sample application. Otherwise, you can download the sample application. Choose one of the following options.
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" data-target="#git">Clone with git</a></li>
<li><a data-toggle="tab" data-target="#download">Download</a></li>
</ul>
<div class="tab-content">
<div id="git" class="tab-pane fade in active" markdown="1">
### Clone with git
Use the following command in a terminal to clone the sample application repository.
```console
$ git clone https://github.com/docker/welcome-to-docker
```
<hr>
</div>
<div id="download" class="tab-pane fade" markdown="1">
### Download
If you don't have git, download the source and extract it.
[Download the source](https://github.com/docker/
welcome-to-docker/archive/refs/heads/main.zip){: .button .primary-btn}
<hr>
</div>
</div>
## Step 2: Create a Dockerfile in your project folder
To run your code in a container, the most fundamental thing you need is a Dockerfile. A Dockerfile describes what goes into a container. To add a Dockerfile, create a text file called `Dockerfile` with no file extension in the root directory of your project. You can use the following commands to create a Dockerfile.
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" data-target="#mac-linux">Mac / Linux</a></li>
<li><a data-toggle="tab" data-target="#windows">Windows</a></li>
</ul>
<div class="tab-content">
<div id="mac-linux" class="tab-pane fade in active" markdown="1">
### Mac / Linux
In the terminal, run the following commands listed below.
Change directory to the `welcome-to-docker` directory. Replace `/path/to/welcome-to-docker` with the path to your `welcome-to-docker` directory.
```console
$ cd /path/to/welcome-to-docker
```
Create an empty file named `Dockerfile`.
```console
$ touch Dockerfile
```
<hr>
</div>
<div id="windows" class="tab-pane fade" markdown="1">
### Windows
In the Windows Command Prompt, run the following commands listed below.
Change directory to the `welcome-to-docker` directory. Replace `\path\to\welcome-to-docker` with the path to your `welcome-to-docker` directory.
```console
$ cd \path\to\welcome-to-docker
```
Create an empty file named `Dockerfile`.
```console
$ type nul > Dockerfile
```
<hr>
</div>
</div>
## Step 3: Add instructions to your Dockerfile
Using a text editor or code editor, add the following contents to the Dockerfile:
```dockerfile
# syntax=docker/dockerfile:1
# Start your image with a node base image
FROM node:18-alpine
# Create an application directory
RUN mkdir -p /app
# Set the /app directory as the working directory for any command that follows
WORKDIR /app
# Copy the local app package and package-lock.json file to the container
COPY package*.json ./
# Copy local directories to the working directory of our docker image (/app)
COPY ./src ./src
COPY ./public ./public
# Install node packages, install serve, build the app, and remove dependencies at the end
RUN npm install \
&& npm install -g serve \
&& npm run build \
&& rm -fr node_modules
# Specify that the application in the container listens on port 3000
EXPOSE 3000
# Start the app using serve command
CMD [ "serve", "-s", "build" ]
```
## Step 3: Build your first image
An image is like a static version of a container. You always need an image to run a container. Once you have a Dockerfile in your repository, run the following `docker build` command in the project folder to create an image.
```console
$ docker build -t welcome-to-docker .
```
Building the image may take some time. After your image is built, you can view your image in the **Images** tab in Docker Desktop.
## Step 4: Run your container
To run your image as a container, go to the **Images** tab, and then select **Run** in the **Actions** column of your image. When the **Optional settings** appear, specify the **Host port** number `8089` and then select **Run**.
![Running an image in Docker Desktop](images/getting-started-run-image.gif){:width="500px"}
## Step 5: Verify that your container is running
You can use Docker Desktop to view and access running containers. Go to the **Containers** tab to view your container and select the link in the **Port(s)** column or go to [http://localhost:8089](http://localhost:8089){:target="_blank" rel="noopener" class="_"} to verify that the application is running.
## What's next
In this guide, you built your own image. When running containers on Docker Desktop, you dont need to build your own image from scratch. You can also run images created by others on Docker Hub.
[Run Docker Hub images](./run-docker-hub-images.md){: .button .primary-btn}
## Dive deeper
### Language-specific guides
If you want to learn more about creating images for applications in other languages, check out the following language-specific guides:
- [Node.js](../language/nodejs/index.md)
- [Python](../language/python/index.md)
- [Go](../language/golang/index.md)
- [Java](../language/java/index.md)
- [C# (.NET)](../language/dotnet/index.md)
### Breaking down the `docker build` command
When you built the image, you used the `docker build` command. Here are what the different parts of the `docker build` command do:
- `docker build`: This command builds the image. It needs one argument, the source folder for the Dockerfile that needs to be built. In this case, its the Dockerfile in the current folder, `.`.
- `-t welcome-to-docker`: The `-t` flag tags the image with a unique name. In this case, `welcome-to-docker`.

View File

@ -0,0 +1,60 @@
---
title: What is a container?
keywords: get started, quick start, intro, concepts
description: Learn what a container is by seeing and inspecting a running container.
---
A container is an isolated environment for your code. This means that a container has no knowledge of your operating system, or your files. It runs on the environment provided to you by Docker Desktop. This is why a container usually has everything that your code needs in order to run, down to a base operating system. You can use Docker Desktop to manage and explore your containers.
Continue with the following steps to view and explore an actual container in Docker Desktop.
## Step 1: Set up the guide
The first thing you need is a running container. For this guide, use the premade `welcome-to-docker` container. To get started, start Docker Desktop and then run the following command in your local terminal:
```console
$ docker run -p 8088:80 -d --name welcome-to-docker docker/welcome-to-docker
```
## Step 2: View containers on Docker Desktop
You just ran a container! Open Docker Desktop to take a look. This container runs a simple web server that displays HTML text. When working with more complex projects, you'll run different parts in different containers. For example, a different container for the frontend, backend, and database. In this guide, you only have a simple frontend container.
![Docker Desktop with get-started container running](images/getting-started-container.png){:width="500px"}
## Step 3: View the frontend
The frontend is accessible on port 8088 of your local host. Select the link in the **Port(s)** column of your container, or visit [http://localhost:8088](http://localhost:8088){:target="_blank" rel="noopener" class="_"} in your browser to check it out.
![Accessing container frontend from Docker Desktop](images/getting-started-frontend.png){:width="500px"}
## Step 4: Explore your container
Docker Desktop allows you to easily view and interact with different aspects of your container. Try it out yourself. Select your container and then select **Files** to explore your container's isolated file system.
![Viewing container details in Docker Desktop](images/getting-started-explore-container.gif){:width="500px"}
## Step 5: Stop your container
The `welcome-to-docker` container continues to run until you stop it. To stop the container in Docker Desktop, go to the **Containers** tab and select the **Stop** icon in the **Actions** column of your container.
![Stopping a container in Docker Desktop](images/getting-started-stop.png){:width="500px"}
## What's next
In this guide, you explored what a container is. Continue to the next guide to learn what you need to create and run your own container.
[Run your own container](./run-your-own-container.md){: .button .primary-btn}
## Dive deeper
### Breaking down the `docker run` command
When setting up the container, you used the `docker run` command. Here are what the different parts of the command do:
- `docker run`: This is used to run containers. It needs at least one argument, and that argument is the image you want to run. In this case, it's `docker/welcome-to-docker`.
- `-p 8088:80`: This lets Docker know that port 80 in the container needs to be accessible from port 8088 on your local host.
- `-d`: This runs the container detached or in the background.
- `—-name welcome-to-docker`: This sets the name for your container. If you dont do so, Docker selects a random name for you.
Continue following [What's next](#whats-next) to learn how to intuitively run an image using the Docker Desktop GUI.