學習Docker的3個理由

學習Docker的3個理由

輕鬆開發,部署和分發應用程序

 

The 3 reasons you should learn Docker

Develop, Deploy, and Distribute Applications with ease

 

我認爲,Docker大大改善了軟件產品和平臺的開發,部署和分發

In my opinion, Docker significantly improves development, deployment, and distribution of software products and platforms.

 

1)跨平臺環境中的開發更容易

Development in a cross-platform environment is easier

如果您像我一樣,那麼您會喜歡運行OSX的Mac。問題是,我部署的大多數代碼都在基於Linux的計算機上運行。

我開發的代碼可以在雲上運行,或者我的代碼可以在Raspberry PI等嵌入式系統上運行。

 

If you are like me, you love your Mac running OSX. The problem is, most of the code that I deploy runs on Linux based

machines. I develop code to run on the cloud or I develop code to run on embedded systems like a Raspberry PI.

 

但是,我不能放棄OSX作爲日常使用的操作系統和開發環境。Linux作爲通用操作系統對我來說並不適合。

在我看來,這很醜陋,並且沒有我一天中需要的所有應用程序。

 

However, I can’t give up OSX as my daily use operating system and development environment.

Linux just doesn’t cut it for me as a general use operating system. In my opinion,

it’s ugly and just doesn’t have all the applications I need to get through my day.

 

這樣便有了Docker。我可以在本地開發環境中的OSX上開發和運行代碼,但是當需要在基於Linux的平臺上運行代碼時,

幾乎沒有任何變化。實際上,由於代碼依賴性,我經常會在沒有Docker的情況下無法在OSX上開發代碼,但是有了Docker,

我們可以在很多情況下消除這些問題。

 

So that’s where Docker comes in. I can develop and run my code on OSX in my local development environment,

but when it’s time to run my code on a Linux based platform, almost nothing changes.

In fact quite often I would never be able to develop my code on OSX without Docker due to code dependencies,

but with Docker we are able to eliminate those issues in many cases.

 

我在OSX機器上構建的完全相同的Docker映像可以在Linux上運行(假設已安裝Docker引擎),從而確保了可移植性。

實際上,當您開始使用Docker註冊表時,這使部署變得無縫。這是我的下一點。

 

The same exact Docker image that I build on my OSX machine can run on Linux (assuming the Docker engine is installed

of course), ensuring portability. In fact, when you start to use Docker registries, this make deployment seamless;

which is my next point.

 

2)應用程序的部署更容易 

Deployment of Applications is easier

如果您曾經嘗試部署具有大量軟件依賴項的軟件應用程序,那麼您會知道這是一個非常痛苦的過程。

在基於Linux的系統上,爲了能夠運行您的代碼,通常會針對不同的軟件項目進行大量的apt-get安裝。

 

If you have ever tried to deploy a software application with a large number of software dependencies,

you know it can be a very painful process. On a Linux based system, it often involves a lot of apt-get installs for

different software projects just to be able to run your code.

 

使用Docker,所有這些依賴項都內置在映像本身中。這意味着,當您要將應用程序部署到內置於Docker映像中的應用程序時,

只需在Docker映像上安裝在系統本身即可。

 

With Docker, all of those dependencies are built into the image itself. This means that when you want to deploy your

application built into a Docker image, all you need installed on the system itself is Docker plus the image.

 

這大大加快了新計算機上的部署過程,並且總體上簡化了事情。通過將docker compose之類的工具連接到Docker註冊表,

您可以僅使用幾個命令來部署系統。

 

This significantly speeds up the deployment process on a new machine, and also simplifies things in general.

With tools such as docker compose connected to a Docker registry, you can deploy a system with just a few commands.

 

3)分發您的應用程序更容易

Distribution of Your Application is easier

如上所述,使用Docker註冊表,假設您已安裝Docker映像和Docker引擎,將應用程序部署到新系統非常簡單。

As we mentioned above, using a docker registry, it is very straight forward to deploy an application to a new system

assuming you have the Docker image plus the Docker engine installed.

 

這使得將應用程序分發給其他人非常容易,因爲您要做的就是構建一個Docker映像並將其上載到DockerHub這樣的註冊表中。

在很多情況下,我都用它來部署其他公司或開源項目的應用程序。由於他們已經完成了構建映像的所有工作,

因此您可以擔心將其部署在系統上。

 

This makes it very easy to distribute your application to others because all you have to do is build a Docker image and

upload it to a registry such as DockerHub. I have used this in many cases to deploy applications from other companies or

open source projects. Since they have done all of the work to build the image, you can just worry about deploying it on

your system.

 

雖然我確實相信Docker是一個很棒的平臺,並且可以解決許多軟件問題,但它並非沒有代價。

通常,編碼和開發會帶來額外的複雜性,尤其是當運行映像(稱爲容器)必須與主機操作系統進行交互時。

 

While I do believe Docker is a fantastic platform and solves many software issues, it doesn’t come without a cost.

Often the coding and development has an extra level of complexity, especially if the running image (called a container)

must interact with the host operating system.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章