mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-03-09 01:30:10 +08:00
translated
This commit is contained in:
parent
4c7581871c
commit
ddb10d0c75
@ -1,83 +0,0 @@
|
||||
[#]: subject: "Experiment with containers and pods on your own computer"
|
||||
[#]: via: "https://opensource.com/article/22/5/containers-pods-101-ebook"
|
||||
[#]: author: "Seth Kenlon https://opensource.com/users/seth"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "geekpi"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
Experiment with containers and pods on your own computer
|
||||
======
|
||||
Start exploring the essentials of container technology with this new downloadable guide.
|
||||
|
||||
![Looking at a map][1]
|
||||
|
||||
(Image by: opensource.com)
|
||||
|
||||
In the TV show *Battlestar Galactica*, the titular mega-ship didn't actually do a whole lot. It served as a stalwart haven for its crew, a central point of contact for strategy and orchestration, and a safe place for resource management. However, the Caprican Vipers, one-person self-contained space vessels, went out to deal with evil Cylons and other space-borne dangers. They never just send one or two Vipers out, either. They sent lots of them. Many redundant ships with essentially the same capabilities and purpose, but thanks to their great agility and number, they always managed to handle whatever problem threatened the Battlestar each week.
|
||||
|
||||
If you think you're sensing a developing analogy, you're right. The modern "cloud" is big and hulking, an amalgamation of lots of infrastructure spread over a great distance. It has great power, but you'd be wasting much of its capability if you treated it like a regular computer. When you want to handle lots of data from millions of input sources, it's actually more efficient to bundle up your solution (whether that takes the form of an application, website, database, server, or something else) and send out tiny images of that solution to deal with clusters of data. These, of course, would be *containers*, and they're the workforce of the cloud. They're the little solution factories you send out to handle service requests, and because you can spawn as many as you need based on the requests coming in at any given time, they're theoretically inexhaustible.
|
||||
|
||||
### Containers at home
|
||||
|
||||
If you don't have a lot of incoming requests to deal with, you might wonder what benefit containers offer to you. Using containers on a personal computer does have its uses, though.
|
||||
|
||||
#### Containers as virtual environments
|
||||
|
||||
With tools like Podman, LXC, and Docker, you can run containers the same way you might have historically run virtual machines. Unlike a virtual machine, though, containers don't require the overhead of emulated firmware and hardware.
|
||||
|
||||
You can download container images from public repositories, launch a minimalist Linux environment, and use it as a testing ground for commands or development. For instance, say you want to try an application you're building on Slackware Linux. First, search for a suitable image in the repository:
|
||||
|
||||
```
|
||||
$ podman search slackware
|
||||
```
|
||||
|
||||
Then select an image to use as the basis for your container:
|
||||
|
||||
```
|
||||
$ podman run -it --name slackware vbatts/slackware
|
||||
sh-4.3# grep -i ^NAME\= /etc/os-release
|
||||
NAME=Slackware
|
||||
```
|
||||
|
||||
### Containers at work
|
||||
|
||||
Of course, containers aren't just minimal virtual machines. They can be highly specific solutions for very specific requirements. If you're new to containers, it might help to start with one of the most common rites of passage for any new sysadmin: Starting up your first web server but in a container.
|
||||
|
||||
First, obtain an image. You can search for your favorite distribution using the `podman search` command or just search for your favorite httpd server. When using containers, I tend to trust the same distributions I trust on bare metal.
|
||||
|
||||
Once you've found an image to base your container on, you can run your image. However, as the term suggests, a container is *contained*, so if you just launch a container, you won't be able to reach the standard HTTP port. You can use the `-p` option to map a container port to a standard networking port:
|
||||
|
||||
```
|
||||
$ podman run -it -p 8080:80 docker.io/fedora/apache:latest
|
||||
```
|
||||
|
||||
Now take a look at port 8080 on your localhost:
|
||||
|
||||
```
|
||||
$ curl localhost:8080
|
||||
Apache
|
||||
```
|
||||
|
||||
Success.
|
||||
|
||||
### Learn more
|
||||
|
||||
Containers hold much more potential than just mimicking virtual machines. You can group them in pods, construct automated deployments of complex applications, launch redundant services to account for high demand, and more. If you're just starting with containers, you can [download our latest eBook][2] to study up on the technology and even learn to create a pod so you can run WordPress and a database.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/22/5/containers-pods-101-ebook
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/seth
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://opensource.com/sites/default/files/lead-images/tips_map_guide_ebook_help_troubleshooting_lightbulb_520.png
|
||||
[2]: https://opensource.com/downloads/containers-pods-101-ebook
|
@ -0,0 +1,83 @@
|
||||
[#]: subject: "Experiment with containers and pods on your own computer"
|
||||
[#]: via: "https://opensource.com/article/22/5/containers-pods-101-ebook"
|
||||
[#]: author: "Seth Kenlon https://opensource.com/users/seth"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "geekpi"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
在自己的电脑上实验容器和 pod
|
||||
======
|
||||
通过这个新的可下载指南开始探索容器技术的要领。
|
||||
|
||||
![Looking at a map][1]
|
||||
|
||||
(图片由:opensource.com)
|
||||
|
||||
在电视剧 *Battlestar Galactica* (太空堡垒卡拉狄加)中,这艘名副其实的巨型飞船并没有做什么。它是船员们坚守的庇护所,是战略和协调的中心联络点,也是资源管理的安全场所。然而,卡布里安毒蛇号,一个人的独立太空船,出去对付邪恶的赛昂人和其他太空中的危险。他们也从不只派一两艘毒蛇号出去。他们派了很多。许多冗余的飞船具有基本相同的能力和目的,但由于它们非常灵活和数量众多,它们总是能够处理每周威胁战星的任何问题。
|
||||
|
||||
如果你认为你正在感知一个发展中的类比,那么你是对的。 现代“云”又大又笨重,是分布在很远距离的大量基础设施的融合。它具有强大的功能,但如果你将其视为普通计算机,你将浪费它的大部分功能。当你想要处理来自数百万输入源的大量数据时,捆绑你的解决方案(无论是采用应用、网站、数据库、服务器还是其他形式)并发送该解决方案的微小镜像来处理数据集群,实际上是更有效的。当然,这些将是*容器*,它们是云的劳动力。它们是你发送来处理服务请求的小型解决方案工厂,并且由于你可以根据任何给定时间传入的请求生成任意数量的解决方案,因此理论上它们是取之不尽的。
|
||||
|
||||
### 家中的容器
|
||||
|
||||
如果你没有大量的传入请求需要处理,你可能会想知道容器给你带来什么好处。不过,在个人电脑上使用容器确实有其用途。
|
||||
|
||||
#### 容器作为虚拟环境
|
||||
|
||||
通过 Podman、LXC 和 Docker 等工具,你可以像以往运行虚拟机一样运行容器。不过,与虚拟机不同,容器不需要模拟固件和硬件的开销。
|
||||
|
||||
你可以从公共仓库下载容器镜像,启动一个最小化的 Linux 环境,并将其作为命令或开发的测试场所。例如,假设你想试试你在 Slackware Linux 上构建的一个应用。首先,在仓库中搜索一个合适的镜像:
|
||||
|
||||
```
|
||||
$ podman search slackware
|
||||
```
|
||||
|
||||
然后选择一个镜像,作为你的容器的基础:
|
||||
|
||||
```
|
||||
$ podman run -it --name slackware vbatts/slackware
|
||||
sh-4.3# grep -i ^NAME\= /etc/os-release
|
||||
NAME=Slackware
|
||||
```
|
||||
|
||||
### 工作中的容器
|
||||
|
||||
当然,容器不只是最小的虚拟机。他们可以为非常具体的需求提供高度具体的解决方案。如果你不熟悉容器,那么对任何新系统管理员最常见的通过仪式之一开始可能会有所帮助:在容器中启动你的第一个 Web 服务器。
|
||||
|
||||
首先,获得一个镜像。你可以使用 `podman search` 命令来搜索你喜欢的发行版,或者直接搜索你喜欢的 httpd 服务器。当使用容器时,我倾向于信任我在裸机上信任的相同发行版。
|
||||
|
||||
当你你找到一个镜像作为你的容器的基础,你就可以运行你的镜像。然而,正如这个术语所暗示的,容器是*被容器化的*,所以如果你只是启动一个容器,你将无法访问标准的 HTTP 端口。你可以使用 `-p` 选项将一个容器端口映射到一个标准的网络端口:
|
||||
|
||||
```
|
||||
$ podman run -it -p 8080:80 docker.io/fedora/apache:latest
|
||||
```
|
||||
|
||||
现在看看你本地主机上的 8080 端口:
|
||||
|
||||
```
|
||||
$ curl localhost:8080
|
||||
Apache
|
||||
```
|
||||
|
||||
成功了。
|
||||
|
||||
### 了解更多
|
||||
|
||||
容器拥有比模仿虚拟机更多的潜力。你可以将它们分组在 pod 中,构建复杂应用的自动部署,启动冗余服务以满足高需求等等。如果你刚刚开始使用容器,你可以[下载我们最新的电子书][2]来学习该技术,甚至学习创建一个 pod,以便你可以运行 WordPress 和数据库。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/22/5/containers-pods-101-ebook
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/seth
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://opensource.com/sites/default/files/lead-images/tips_map_guide_ebook_help_troubleshooting_lightbulb_520.png
|
||||
[2]: https://opensource.com/downloads/containers-pods-101-ebook
|
Loading…
Reference in New Issue
Block a user