docker引导java_让我引导您完成与Docker的第一次约会

docker引导java

安装Docker,创建第一个容器等 (Install Docker, create your first container, and more)

You may have seen Docker somewhere on the internet and you may feel curious about it. Now you want to take it to the next level. How about going on a date with Docker? No — I am not kidding!

您可能已经在互联网上的某个地方看到了Docker,并且可能对此感到好奇。 现在,您想将它带入一个新的水平。 与Docker约会怎么样? 不,我不是在开玩笑!

But, how do you plan a perfect first date? What should you do? Where to find the right resources? What prerequisites might you need?

但是,您如何计划一次完美的初次约会? 你该怎么办? 在哪里找到合适的资源? 您可能需要哪些先决条件?

The questions are endless. Follow these first-date guidelines, and you’ll be well on your way to landing a second.

问题是无止境的。 遵循这些最新的准则,您将步入第二个良好的状态。

计划你的约会 (Planning your date)

Getting to know your date before you start planning is crucial to crafting a memorable first experience. It will likely boost your confidence during the meeting, as well.

在开始计划之前了解您的日期对于打造难忘的初体验至关重要。 在会议期间,它也可能会增强您的信心。

It’s never too late to say Hi. Here is a short introduction to my first time meeting Docker if you’re interested.

嗨,永远不会太晚。 如果您有兴趣, 是我第一次与Docker会面的简短介绍。

Okay! So the road map we will follow today looks something like this:

好的! 因此,我们今天将遵循的路线图如下所示:

  1. Setting up the Venue

    设置场地
  2. The Pickup

    接送
  3. The Conversation

    谈话

序幕 (Prelude)

The place where we will set up our date is the Docker engine.

我们安排约会的地方是Docker引擎。

Docker engine is no different from any other engine. It is a combination of various components working together.

Docker引擎与任何其他引擎没有什么不同。 它是一起工作的各种组件的组合。

We will see a few of these components later in this article. But for now, let’s decorate our machine with Docker. The installation process depends upon your operating system.

我们将在本文后面看到其中一些组件。 但是现在,让我们用Docker装饰我们的机器。 安装过程取决于您的操作系统。

The key for uninterrupted execution is always to refer to an official website. Docker has this fantastic guide, where you can find out more about installation.

不间断执行的关键始终是指向官方网站。 Docker有一个很棒的指南 ,您可以在其中找到有关安装的更多信息。

Docker comes in two flavors: Docker Community Edition (CE) and Docker Enterprise Edition (E.E.). For our demonstration purposes, we must stick to the community edition. The Enterprise Edition is paid. And besides, making an expensive reservation for your first date is not the best idea ?

Docker有两种形式:Docker社区版(CE)和Docker企业版(EE)。 出于演示目的,我们必须坚持使用社区版。 企业版是付费的。 此外,为您的第一次约会进行昂贵的预订不是最好的主意吗?

地点 (The Venue)

The core mantra for any propitious date is to choose the right meeting place. Meeting Docker is no different. First, we should decide on the platform. Cloud? Mac? Linux? Or Windows? Once we know our environment, we can choose the simplest way to set up the meeting place.

任何合适日期的核心口号是选择合适的聚会地点。 与Docker会面也不例外。 首先,我们应该决定平台。 云? 苹果电脑? Linux的? 还是Windows? 了解我们的环境后,我们可以选择最简单的方式来设置会议场所。

视窗 (Windows)

If your choice is Windows, the process for setup is quite simple. Remember our favorite process: Next, Next, Next, and Finish.

如果您选择的是Windows,则安装过程非常简单。 记住我们最喜欢的过程:“下一步”,“下一步”,“下一步”和“完成”。

Jump to the download page and choose the “Edge channel.” Edge has experimental features and fits best for our learning purposes.

跳至下载页面,然后选择“边缘通道”。 Edge具有实验功能,最适合我们的学习目的。

Note! Docker for Windows needs the “Hyper-V” feature, but there is nothing to worry about — Docker will turn it on for you. However, it means that you can’t use Virtual Box.

注意! 适用于Windows的Docker需要具有“ Hyper-V”功能,但无需担心-Docker会为您打开它。 但是,这意味着您无法使用Virtual Box。

的Linux (Linux)

When I first started experimenting on a Linux box, I thought it was going to be a nightmare. But to my relief, setting up Docker on a Linux distribution turned out to be simple. Again, there are many ways to install Docker on a Linux distribution.

当我刚开始在Linux机器上进行实验时,我认为这将是一场噩梦。 但是令我欣慰的是,事实证明,在Linux发行版上设置Docker非常简单。 同样,有很多方法可以在Linux发行版上安装Docker。

My favorite is: “Install using the convenience script.” We grab a long shell script from the internet and then pipe it to a shell terminal.

我最喜欢的是:“使用便捷脚本进行安装。” 我们从互联网上获取一个长的Shell脚本,然后将其通过管道传输到Shell终端。

How? Like this:

怎么样? 像这样:

sudo wget -qO- https://get.docker.com |sh

Done! Yeah, you have Docker on your machine up and running.

完成 ! 是的,您已经在计算机上启动并运行了Docker。

Now that the venue is all set, we are ready to proceed. But first, let’s make some inquiries to make sure everything is working fine here. The same as you might inquire with a restaurant before booking a table ?.

既然场地已经准备好,我们就可以开始了。 但是首先,让我们进行一些查询,以确保此处一切正常。 就像您在预订餐桌前向餐厅咨询一样。

Let’s execute the below command in the terminal:

让我们在终端中执行以下命令:

docker version

You should see the installation details. It gives you information about the Client and Server version, the Go-lang version, and so on and so forth.

您应该看到安装详细信息。 它为您提供有关客户端服务器的信息 版本, Go-lang版本等等。

If the output of your command is somehow like the one below, the sun is shining, and the world is beautiful. Next: time to get ready for the “Pickup.”

如果您的命令输出类似于下面的命令,则说明太阳照耀着,世界就美好了。 下一步 :是时候准备“接机”了。

接送 (The Pickup)

As you may already be aware, Docker uses Images to create containers. These images are large binary immutable files.

您可能已经知道,Docker使用Images创建容器。 这些图像是大型二进制不可变文件。

An image contains application binaries and their dependencies. It may also contain other components such as a web server or even an OS.

映像包含应用程序二进制文件及其依赖项。 它还可能包含其他组件,例如Web服务器或OS。

We will need such images to create a container and run an application inside it.

我们将需要这样的图像来创建容器并在其中运行应用程序。

So, where do these images live? Simple question, simple answer: on a Host. This host can be your machine or a registry somewhere on the internet. Docker has its registry called Docker-Hub.

那么,这些图像住在哪里? 简单的问题,简单的答案:在主机上。 该主机可以是您的计算机,也可以是Internet上某个地方的注册表。 Docker的注册表称为Docker-Hub。

为避免徘徊,您应该知道约会的正确接送地点。 (To avoid wandering, you should know the right pickup location for your date.)

To make your first date smoother, I found the exact location of an image that I can share with you. Excited enough? Here you go!

为了使您的初次约会更顺利,我找到了可以与您共享的图像的确切位置。 激动了吗? 干得好!

docker pull chandrabhan/dotnetconsole

Let’s confirm that we are at the right location. ?

让我们确认我们在正确的位置。 ?

docker image ls

Here you can see various properties of the images on your machine. Cool, it looks like things are going good so far.

在这里,您可以看到计算机上图像的各种属性。 太酷了,到目前为止看起来一切都很好。

Before moving further, let’s break down the previous two commands and understand what’s going on here.

在继续之前,让我们分解前面的两个命令并了解这里发生的情况。

With Docker pull, we asked Docker Daemon to pull an image for us. The Daemon could not find the image in the local registry, so it went ahead and pulled a remote copy from Docker-Hub.

使用Docker pull ,我们要求Docker Daemon为我们提取一个映像。 守护程序无法在本地注册表中找到该映像,因此它继续进行并从Docker-Hub中提取了一个远程副本。

Through docker image ls we saw all available images and their properties.

通过docker image ls我们看到了所有可用的图像及其属性。

I must admit, I am getting excited. We’ve done a great job so far. Next, let the interaction begin.

我必须承认,我很兴奋。 到目前为止,我们做得很好。 接下来,让交互开始。

谈话 (The Conversation)

开始对话,一切都会对您有利。 (Start the conversation, and things will turn out in your favor.)

So again, to make it smoother for you, I want to offer you a few icebreakers.

再说一次,为了让您更轻松,我想向您提供一些破冰船。

We will create some containers for .Net Core framework applications. The first one will be a simple console application. The other will be a bit more colorful — a web application.

我们将为.Net Core框架应用程序创建一些容器。 第一个将是一个简单的控制台应用程序。 另一个会更加丰富多彩-一个Web应用程序。

docker run chandrabhan/dotnetconsole

Magnificent! Did you see what happened there? This stuff is amazing. A .Net core application is running inside a container. Docker went ahead and created a container and executed the application inside it. And as soon as the console application ends, the container exists!

壮丽的! 你看到那里发生了什么吗? 这东西太神奇了。 .Net核心应用程序正在容器内运行。 Docker继续创建了一个容器,并在其中执行了应用程序。 控制台应用程序结束后,容器就存在了!

Let’s see how many containers we have in our machine:

让我们看看我们的机器中有多少个容器:

docker container ls -a

What you see here is the list of containers on your machine. You can identify a container by its ID. The output tells us when the container was CREATED and what it’s current STATUS is. The container we created is in Exited status. Remember? Our application is exited! So is the container.

您在此处看到的是计算机上的容器列表。 您可以通过ID识别容器。 输出告诉我们何时CREATED容器以及容器的当前STATUS 是。 我们创建的容器处于Exited状态。 记得? 我们的申请已退出! 容器也是如此。

It looks like the conversation is progressing well, so let’s keep going.

对话似乎进展顺利,所以让我们继续吧。

docker run -it --rm -p 5000:80 --name app chandrabhan/aspdotnet

Go to your favorite browser and browse http://localhost:5000. You should see more amazing stuff.

转到您喜欢的浏览器并浏览http://localhost:5000 。 您应该会看到更多令人惊奇的东西。

An ASP.Net core web app is running inside a container:

ASP.Net核心Web应用程序在容器内运行:

Before moving further, let’s see the anatomy of the above command.

在继续之前,让我们看一下上面命令的剖析。

Did you notice? This time we did not pull the image, but we were still able to create a container out of it. When you execute docker run, Docker daemon tries to find a local copy of the image. If it cannot, it goes ahead and tries to find it in the default registry (Docker-Hub in this case).

你注意到了吗? 这次我们没有拉出图像,但是我们仍然能够从中创建一个容器。 当您执行docker run ,Docker守护程序会尝试查找映像的本地副本。 如果不能,它将继续尝试在默认注册表(在本例中为Docker-Hub)中找到它。

I believe our planning was excellent and so was the execution. Let’s rewind what we did and review how we planned an auspicious date with Docker ?.

我相信我们的计划很棒,执行力也很棒。 让我们回顾一下我们所做的事情,并回顾一下我们如何计划与Docker的吉祥约会。

倒带 (Rewinding)

  1. First, we installed Docker. We saw how the installation process varies depending on the operating system.

    首先,我们安装了Docker。 我们看到了安装过程如何随操作系统而变化。
  2. Then we went ahead and pulled an image from the Docker-Hub registry, a simple .Net Core console app.

    然后,我们继续从Docker-Hub注册表(一个简单的.Net Core控制台应用程序)中提取图像。
  3. Once we had this image on our machine, we used Docker to create a container out of this image.

    在机器上拥有此映像后,我们便使用Docker从该映像创建了一个容器。
  4. We also saw how to pull an image and run a container through a single command.

    我们还看到了如何通过单个命令提取图像并运行容器。

Here is an illustration that may help you understand a high-level picture.

这是一个插图,可以帮助您了解高级图片。

跟进 (Follow up)

眼不见,心不烦 (Out of sight out of mind)

Following up is as important as any other stage during the date. Now I should leave you with your date, and would like to hear how it went. Below are a few links that may be useful:

在此期间,跟进其他任何阶段一样重要。 现在,我应该把您的约会日期留给您,并想听听它的进展情况。 以下是一些可能有用的链接:

翻译自: https://www.freecodecamp.org/news/let-me-guide-you-through-your-first-date-with-docker-f03f35567d95/

docker引导java

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值