使用 Minikube 设置 Docker Engine 时采用哪种方法可以避免未来的问题?

huangapple go评论68阅读模式
英文:

Which approach to setting up Docker Engine on Minikube will avoid future issues?

问题

我正在使用Minikube在我的本地计算机上设置Docker Engine。有两个教程我考虑过,它们之间有一些细微的差异。我想了解它们之间的区别。有人可以澄清这些命令是否会有任何不同的结果吗?

来自这个博客帖子,我首先找到的:

# 安装 hyperkit 和 minikube
brew install hyperkit
brew install minikube

# 安装 Docker CLI
brew install docker
brew install docker-compose

# 启动 minikube
minikube start

# 告诉 Docker CLI 与 minikube 的虚拟机通信
eval $(minikube docker-env)

# 将 IP 保存到主机名
echo "`minikube ip` docker.local" | sudo tee -a /etc/hosts > /dev/null

# 测试
docker run hello-world

或者来自这个教程(在 minikube 网站上,我倾向于相信它是权威的):

# 安装 Docker CLI
brew install docker

# 使用 VM 驱动程序和 `docker` 容器运行时(如果尚未运行)启动 minikube。
minikube start --container-runtime=docker --vm=true

# 使用 `minikube docker-env` 命令将终端的 Docker CLI 指向 minikube 中的 Docker 实例。
eval $(minikube -p <profile> docker-env)

背景信息:我使用的是 MacOS,Ventura 13.0(22A380)

注:这是一个与这个具体问题相关的更一般性的问题链接

英文:

I'm setting up Docker Engine on my local machine using Minikube. There are two tutorials I've considered, with slight differences between them. I'd love to understand the difference. Can anyone clarify whether these commands would have any different outcome?

From this blog post, which I found first:

# Install hyperkit and minikube
brew install hyperkit
brew install minikube

# Install Docker CLI
brew install docker
brew install docker-compose

# Start minikube
minikube start

# Tell Docker CLI to talk to minikube&#39;s VM
eval $(minikube docker-env)

# Save IP to a hostname
echo &quot;`minikube ip` docker.local&quot; | sudo tee -a /etc/hosts &gt; /dev/null

# Test
docker run hello-world

Or from this tutorial (on the minikube website, which I'm inclined to believe is authoritative):

# Install the Docker CLI
brew install docker

# Start minikube with a VM driver and `docker` container runtime if not already running.
minikube start --container-runtime=docker --vm=true

# Use the `minikube docker-env` command to point your terminal&#39;s Docker CLI to the Docker instance inside minikube.
eval $(minikube -p &lt;profile&gt; docker-env)

Context: I'm on MacOS, Ventura 13.0 (22A380)

Note: This is a more general question related to the specific one here.

答案1

得分: 1

根据 Bijendra 的说明,这两个教程基本相同,只有极小的差异。echo "minikube ip docker.local" | sudo tee -a /etc/hosts > /dev/null 命令会获取 IP 地址,并在你的 /etc/hosts 文件中添加条目,这样你就可以通过主机名而不是 IP 地址来 ping 你的机器。

既然你说你是个初学者,我希望下面的链接对你有所帮助。愉快学习!

1 https://kubernetes.io/docs/tutorials/hello-minikube/

2 https://devopscube.com/kubernetes-minikube-tutorial/

3 https://www.youtube.com/watch?v=E2pP1MOfo3g

英文:

As eloborated by Bijendra, both tutorials are same with very minimal difference. The echo &quot;minikube ip docker.local&quot; | sudo tee -a /etc/hosts &gt; /dev/null command is fetching the IP address and is making an entry in your /etc/hosts file by doing this you can ping your machine using hostname instead of using IP address every time.

Since you are saying that you are a beginner. I hope the links below might help you. Happy learning.

[1]https://www.kubernetes.io/docs/tutorials/hello-minikube

[2]https://www.devopscube.com/kubernetes-minikube-tutorial

[3]https://www.youtube.com/watch?v=E2pP1MOfo3g

huangapple
  • 本文由 发表于 2023年2月13日 23:03:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/75437625.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定