[英]Cannot connect to other container in kubernetes pod through localhost
I'm trying to launch docker-in-docker so that I can connect to it in a different container in the same Kubernetes pod.我正在尝试启动 docker-in-docker 以便我可以在同一个 Kubernetes pod 中的不同容器中连接到它。 I am using the following yaml:
我正在使用以下 yaml:
apiVersion: batch/v1
kind: Job
metadata:
name: {{job_name}}
labels:
taskType: store_v510
taskName: {{task_name}}
spec:
template:
spec:
activeDeadlineSeconds: 86400
volumes:
- name: hdfs-volume
configMap:
name: hdfs-config
items:
- key: core-site.xml
path: core-site.xml
- key: hadoop-env.sh
path: hadoop-env.sh
- key: hdfs-site.xml
path: hdfs-site.xml
- key: log4j.properties
path: log4j.properties
- name: download-dir
hostPath:
path: /tmp/store_pipeline
- name: docker-graph-storage
emptyDir: {}
containers:
- name: {{job_name}}
envFrom:
- configMapRef:
name: job-configs
env:
- name: DOCKER_HOST
value: tcp://localhost:2375
volumeMounts:
- mountPath: /tmp/store_pipeline
name: download-dir
image: registry.com.cn/com/store_pipeline:0.1
imagePullPolicy: Always
resources:
requests:
cpu: 2
memory: 32Gi
nvidia.com/gpu: 0
limits:
cpu: 2
memory: 40Gi
nvidia.com/gpu: 0
command: ["bash", "run_store_pipeline.sh", "--data_dir", "{{data_dir}}", "--config_dir", "{{config_dir}}", "--output_dir", "{{output_dir}}"]
- name: dind-daemon
image: registry.com.cn/com/1.12.6-dind
resources:
requests:
cpu: 20m
memory: 512Mi
securityContext:
privileged: true
volumeMounts:
- name: docker-graph-storage
mountPath: /var/lib/docker
command: []
Based on the documentation I see, I should be able to connect to the docker-in-docker docker daemon by setting DOCKER_HOST = tcp://localhost:2375.根据我看到的文档,我应该能够通过设置 DOCKER_HOST = tcp://localhost:2375 连接到 docker-in-docker docker 守护进程。 However, I'm not able to do so.
但是,我不能这样做。
I notice that if I test it locally and run these two containers in the same docker network, I'm able to connect them by specifying the actual container name (ie tcp://dind-daemon:2375).我注意到,如果我在本地测试它并在同一个 docker 网络中运行这两个容器,我可以通过指定实际容器名称(即 tcp://dind-daemon:2375)来连接它们。 Thanks!
谢谢!
Your setup seems to be correct.您的设置似乎是正确的。 I assume that the docker image is comparable to a current docker image from the public registry.
我假设 docker 映像与来自公共注册表的当前 docker 映像相当。
That docker-in-docker usually listens only for TLS secured requests on port 2376.该 docker-in-docker 通常仅在端口 2376 上侦听 TLS 安全请求。
If you want to be able to use it on 2375 without mutual TLS authentication you need to set the environment variable DOCKER_TLS_CERTDIR
to an empty value.如果您希望能够在没有相互 TLS 身份验证的情况下在 2375 上使用它,您需要将环境变量
DOCKER_TLS_CERTDIR
设置为空值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.