无法在 Minikube 的 Docker 守护程序中创建 Docker 映像



我正试图将一个映像添加到Minikube中运行的Docker守护进程中,以便可以出于开发目的在本地提取它。

首先,我检查本地安装的Docker镜像的列表

user@kubetest:~/workspace$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
tomcat              9.0                 d5eef28cf41d        2 days ago          647MB
tomcat              latest              d5eef28cf41d        2 days ago          647MB
node                slim                05f62d57259e        6 days ago          167MB
hello-world         latest              bf756fb1ae65        8 months ago        13.3kB
tomcat              8.0                 ef6a7c98d192        24 months ago       356MB

检查minikube配置:

user@kubetest:~/workspace/local-minikube-docker$ minikube docker-env 
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/home/user/.minikube/certs"
export DOCKER_API_VERSION="1.35"
# Run this command to configure your shell:
# eval $(minikube docker-env)

现在我运行命令在Minikube:中使用Docker环境

user@kubetest:~/workspace$ eval $(minikube docker-env)

现在创建Docker镜像:

user@kubetest:~/workspace$ cd local-minikube-docker/
user@kubetest:~/workspace/local-minikube-docker$ sudo docker build -t nodejs-server .
Sending build context to Docker daemon  69.12kB
Step 1/5 : FROM node:slim
---> 05f62d57259e
Step 2/5 : WORKDIR /usr/home
---> Running in 2d9e3d363188
Removing intermediate container 2d9e3d363188
---> 4c862acc9863
Step 3/5 : COPY index.js .
---> 2368cfc6ca5b
Step 4/5 : EXPOSE 3000
---> Running in 61e1081d2f21
Removing intermediate container 61e1081d2f21
---> f99db8ab886d
Step 5/5 : CMD ["node", "index.js"]
---> Running in b1f3de55de63
Removing intermediate container b1f3de55de63
---> 2ea9d8cf073a
Successfully built 2ea9d8cf073a
Successfully tagged nodejs-server:latest

现在检查"本地"Docker镜像列表-它不应该在这里?

user@kubetest:~/workspace/local-minikube-docker$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nodejs-server       latest              2ea9d8cf073a        5 seconds ago       167MB
tomcat              9.0                 d5eef28cf41d        2 days ago          647MB
tomcat              latest              d5eef28cf41d        2 days ago          647MB
node                slim                05f62d57259e        6 days ago          167MB
hello-world         latest              bf756fb1ae65        8 months ago        13.3kB
tomcat              8.0                 ef6a7c98d192        24 months ago       356MB

SSH Into minikube和Docker镜像的检查列表-它应该在这里吗?

_         _  ( )           ( )           
___ ___  (_)  ___  (_)| |/')  _   _ | |_      __  
/' _ ` _ `| |/' _ `| || , <  ( ) ( )| '_`  /'__`
| ( ) ( ) || || ( ) || || |` | (_) || |_) )(  ___/
(_) (_) (_)(_)(_) (_)(_)(_) (_)`___/'(_,__/'`____)
$ docker images
REPOSITORY                                 TAG                 IMAGE ID            CREATED             SIZE
kubernetesui/dashboard                     v2.0.0-beta3        6feddba9df74        13 months ago       75.3MB
kubernetesui/metrics-scraper               v1.0.1              709901356c11        13 months ago       40.1MB
k8s.gcr.io/kube-proxy-amd64                v1.10.0             bfc21aadc7d3        2 years ago         97MB
k8s.gcr.io/kube-scheduler-amd64            v1.10.0             704ba848e69a        2 years ago         50.4MB
k8s.gcr.io/kube-controller-manager-amd64   v1.10.0             ad86dbed1555        2 years ago         148MB
k8s.gcr.io/kube-apiserver-amd64            v1.10.0             af20925d51a3        2 years ago         225MB
k8s.gcr.io/etcd-amd64                      3.1.12              52920ad46f5b        2 years ago         193MB
k8s.gcr.io/kube-addon-manager              v8.6                9c16409588eb        2 years ago         78.4MB
k8s.gcr.io/k8s-dns-dnsmasq-nanny-amd64     1.14.8              c2ce1ffb51ed        2 years ago         41MB
k8s.gcr.io/k8s-dns-sidecar-amd64           1.14.8              6f7f2dc7fab5        2 years ago         42.2MB
k8s.gcr.io/k8s-dns-kube-dns-amd64          1.14.8              80cc5ea4b547        2 years ago         50.5MB
k8s.gcr.io/pause-amd64                     3.1                 da86e6ba6ca1        2 years ago         742kB
k8s.gcr.io/kubernetes-dashboard-amd64      v1.8.1              e94d2f21bc0c        2 years ago         121MB
gcr.io/k8s-minikube/storage-provisioner    v1.8.1              4689081edb10        2 years ago         80.8MB
$ 

为什么在我设置好环境后,图像不被添加到minikube的Docker中?

注意:我也尝试过其他地方推荐的eval $(minikube -p minikube docker-env)

sudo丢弃了大多数环境变量,但在这里没有必要。

您通常需要sudo docker ...的唯一原因是对/var/run/docker.sock文件的访问受到限制;这是因为你可以很容易地使用它来root主机。如果您已经设置了$DOCKER_HOST环境变量,那么您没有使用这个套接字文件,因此您不需要sudo

如果由于其他原因确实需要以root身份运行docker buildsudo -E将保留环境变量。

相关内容

  • 没有找到相关文章

最新更新