在Kubernetes minikube tutorial中,此命令可以使用Minikube Docker守护进程:
$ eval $(minikube docker-env)
此命令的确切作用是什么,即minikube docker-env
的确切含义是什么?
答案 0 :(得分:15)
命令minikube docker-env
返回一组Bash环境变量导出,以配置您的本地环境以重新使用Minikube实例中的Docker守护程序。
将此输出传递给eval
会使bash评估这些导出并使其生效。
您可以通过省略评估步骤并直接运行minikube docker-env
来查看将在Shell中执行的特定命令。但是,这将不会执行配置 –需要为此评估输出。
这是一种工作流程优化,旨在改善您在minikube环境中运行的构建和运行Docker映像的体验。不一定要重新使用minikube的Docker守护程序才能有效地使用minikube,但是这样做会大大提高代码构建-测试-测试周期的速度。
在正常的工作流程中,您的主机上将有一个与minikube中的Docker注册表不同的Docker注册表,这需要以下过程来在minikube中构建和运行Docker映像:
通过在Minikube中重新使用Docker注册表,它将变成:
有关目的的更多详细信息,请参见minikube docs。
答案 1 :(得分:3)
$ curl --verbose --location --max-redirs 3 --ntlm --user "$USERNAME:$PASSWORD" https://my_application.intranet.net/MyApp
* About to connect() to my_application.intranet.net port 443 (#0)
* Trying 10.0.0.139...
* Connected to my_application.intranet.net (10.0.0.139) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
* SSL connection using TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
* Server certificate:
* subject: CN=my_application.intranet.net,OU=WU - Web Hosting,O=...
* start date: Apr 06 00:00:00 2020 GMT
* expire date: Apr 06 23:59:59 2022 GMT
* common name: my_application.intranet.net
* issuer: CN=COMODO RSA Organization Validation Secure Server CA,O=...
* Server auth using NTLM with user 'User'
> GET /MyApp HTTP/1.1
> Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=
> User-Agent: curl/7.29.0
> Host: my_application.intranet.net
> Accept: */*
>
< HTTP/1.1 401 Unauthorized
< Content-Type: text/html; charset=us-ascii
< Server: Microsoft-HTTPAPI/2.0
< WWW-Authenticate: NTLM TlRMTVNTUAACAAAABwAHADgAAAAGgokCRq5F/qQskfcAAAAAAAAAAK4ArgA/AAAABgOAJQAAAA9IUUlOVEwxAgAOAEgAUQBJAE4AVABMADEAAQAcAFcAVQBUAEUAQQBNAEUAVgA5AFcAQgAwADAAMQAEABYASABRAEkATgBUAEwAMQAuAGMAbwBtAAMANAB3AHUAdABlAGEAbQBlAHYAOQBXAEIAMAAwADEALgBoAHEAaQBuAHQAbAAxAC4AYwBvAG0ABQAWAEgAUQBJAE4AVABMADEALgBjAG8AbQAHAAgA8V6tXHTc1gEAAAAA
< Date: Sun, 27 Dec 2020 17:18:58 GMT
< Content-Length: 341
<
* Ignoring the response-body
* Connection #0 to host my_application.intranet.net left intact
* Issue another request to this URL: 'https://my_application.intranet.net/MyApp'
* Found bundle for host my_application.intranet.net: 0x8b4fb0
* Re-using existing connection! (#0) with host my_application.intranet.net
* Connected to my_application.intranet.net (10.0.0.139) port 443 (#0)
* Server auth using NTLM with user 'User'
> GET /MyApp HTTP/1.1
> Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAAFAAUAHAAAAAQABAAhAAAAAAAAAAAAAAABoKJAlEjznrpL4kjAAAAAAAAAAAAAAAAAAAAAOa+8rUwlSu2YqYy1p3J0HHzw0uwDqzvhlNfSmlyYV9JbnRlcm5hbEF1ZGl0aXAtMTAtMzktMTgyLTI0Nw==
> User-Agent: curl/7.29.0
> Host: my_application.intranet.net
> Accept: */*
>
< HTTP/1.1 302 Found
< Content-Type: text/html; charset=utf-8
< Location: /MyApp/
< Server: MyApp Server
< X-Frame-Options: SAMEORIGIN
< X-Content-Type-Options: nosniff
< Date: Sun, 27 Dec 2020 17:18:58 GMT
< Content-Length: 130
<
* Ignoring the response-body
* Connection #0 to host my_application.intranet.net left intact
* Issue another request to this URL: 'https://my_application.intranet.net/MyApp/'
* Found bundle for host my_application.intranet.net: 0x8b4fb0
* Re-using existing connection! (#0) with host my_application.intranet.net
* Connected to my_application.intranet.net (10.0.0.139) port 443 (#0)
* Server auth using NTLM with user 'User'
> GET /MyApp/ HTTP/1.1
> User-Agent: curl/7.29.0
> Host: my_application.intranet.net
> Accept: */*
>
< HTTP/1.1 302 Found
< Cache-Control: private
< Content-Type: text/html; charset=utf-8
< Location: /MyApp/
< Set-Cookie: ASP.NET_SessionId=swt4ivbaajalrwfdm0jshof3; path=/; secure; HttpOnly; SameSite=Lax
< Set-Cookie: MyApp_Cookie=ConnectionTitle=DELwLGx+KbrtS0gKvmretg==&IsConnectionTitleSet=True&IsLogOff=False&CurrentOrganization=ELx658BVmiesDFQg7w5RtA==&IsOrganizationRequired=YBfC/taoB3Ll19UPqF9IEA==; path=/; secure; HttpOnly
< Set-Cookie: .MyApp_SSO_Cookie=ConnectionTitle=DELwLGx+KbrtS0gKvmretg==&IsConnectionTitleSet=True&IsLogOff=True&CurrentOrganization=ELx658BVmiesDFQg7w5RtA==&IsOrganizationRequired=YBfC/taoB3Ll19UPqF9IEA==; path=/; secure; HttpOnly
< Server: MyApp Server
< Persistent-Auth: true
< X-Frame-Options: SAMEORIGIN
< X-Content-Type-Options: nosniff
< Date: Sun, 27 Dec 2020 17:18:58 GMT
< Content-Length: 130
<
* Ignoring the response-body
* Connection #0 to host my_application.intranet.net left intact
* Issue another request to this URL: 'https://my_application.intranet.net/MyApp/'
* Found bundle for host my_application.intranet.net: 0x8b4fb0
* Re-using existing connection! (#0) with host my_application.intranet.net
* Connected to my_application.intranet.net (10.0.0.139) port 443 (#0)
* Server auth using NTLM with user 'User'
> GET /MyApp/ HTTP/1.1
> User-Agent: curl/7.29.0
> Host: my_application.intranet.net
> Accept: */*
>
< HTTP/1.1 302 Found
< Cache-Control: private
< Content-Type: text/html; charset=utf-8
< Location: /MyApp/
< Set-Cookie: ASP.NET_SessionId=v4cjtwk0bmtytcxlkd1w1gmb; path=/; secure; HttpOnly; SameSite=Lax
< Set-Cookie: MyApp_Cookie=ConnectionTitle=DELwLGx+KbrtS0gKvmretg==&IsConnectionTitleSet=True&IsLogOff=False&CurrentOrganization=ELx658BVmiesDFQg7w5RtA==&IsOrganizationRequired=YBfC/taoB3Ll19UPqF9IEA==; path=/; secure; HttpOnly
< Set-Cookie: .MyApp_SSO_Cookie=ConnectionTitle=DELwLGx+KbrtS0gKvmretg==&IsConnectionTitleSet=True&IsLogOff=True&CurrentOrganization=ELx658BVmiesDFQg7w5RtA==&IsOrganizationRequired=YBfC/taoB3Ll19UPqF9IEA==; path=/; secure; HttpOnly
< Server: MyApp Server
< Persistent-Auth: true
< X-Frame-Options: SAMEORIGIN
< X-Content-Type-Options: nosniff
< Date: Sun, 27 Dec 2020 17:18:58 GMT
< Content-Length: 130
<
* Ignoring the response-body
* Connection #0 to host my_application.intranet.net left intact
* Maximum (3) redirects followed
curl: (47) Maximum (3) redirects followed
您会看到其中提到了一些 minikube docker-env
:)
这些变量将帮助您的 environment variables
连接与 docker daemon in the VM 由 minikube 创建!
现在,要将您的 Docker CLI 连接到 docker CLI (where you write docker commands)
,您需要运行:docker daemon inside the VM
这将暂时(对于那个终端)将 CLI 连接到 VM 内的 docker 守护进程:)
现在,尝试执行 eval $(minikube docker-env)
,您可以看到 VM 内部创建的所有容器(只有在您在 k8 的集群中完成了一些工作时才会显示)
由于docker-env的那些环境变量,这一切都是可能的