我在我的Windows10电脑(Ubuntu18.04)上安装了Windows子系统Linux。我在Windows上安装了Docker toolbox,通过虚拟机运行,我可以通过以下设置正常运行Docker命令:
export DOCKER_HOST=tcp://192.168.99.101:2376
我可以很好地访问它并正确安装/运行docker容器。其中一个服务是运行在localhost:8084上的Kafka Connect容器,如果是从我的Windows创建的。如果我直接从Ubuntu子系统运行它,我可以正常地从我的视窗浏览器访问它,但是如果我从视窗子系统中的docker容器运行它,我就不能访问它,就好像端口没有从docker撰写文件正确转发一样...下面是运行此服务的配置:
#
# This docker-compose file starts and runs:
# * A 3-node kafka cluster
# * A 1-zookeeper ensemble
# * Schema Registry
# * Kafka REST Proxy
# * Kafka Connect
#
version: '3.7'
services:
zookeeper:
image: confluentinc/cp-zookeeper:5.2.2
ports:
- "2181:2181"
environment:
ZOOKEEPER_CLIENT_PORT: "2181"
kafka0:
image: confluentinc/cp-kafka:5.2.2
ports:
- "9092:9092"
environment:
KAFKA_BROKER_ID: 0
KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
KAFKA_ADVERTISED_LISTENERS: "INTERNAL://kafka0:19092,EXTERNAL://${DOCKER_HOST_IP:-127.0.0.1}:9092"
KAFKA_INTER_BROKER_LISTENER_NAME: "INTERNAL"
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT"
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: "1"
depends_on:
- "zookeeper"
schema-registry:
image: confluentinc/cp-schema-registry:5.2.2
ports:
- "8081:8081"
environment:
SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: "PLAINTEXT://kafka0:19092"
SCHEMA_REGISTRY_LISTENERS: "http://0.0.0.0:8081"
SCHEMA_REGISTRY_HOST_NAME: "schema-registry"
SCHEMA_REGISTRY_KAFKASTORE_TOPIC_REPLICATION_FACTOR: "1"
depends_on:
- "kafka0"
rest-proxy:
image: confluentinc/cp-kafka-rest:5.2.2
ports:
- "8082:8082"
environment:
KAFKA_REST_BOOTSTRAP_SERVERS: "PLAINTEXT://kafka0:19092"
KAFKA_REST_LISTENERS: "http://0.0.0.0:8082/"
KAFKA_REST_HOST_NAME: "rest-proxy"
KAFKA_REST_SCHEMA_REGISTRY_URL: "http://schema-registry:8081/"
depends_on:
- "kafka0"
- "schema-registry"
connect:
image: confluentinc/cp-kafka-connect:5.2.2
ports:
- "8083:8083"
environment:
CONNECT_BOOTSTRAP_SERVERS: "PLAINTEXT://kafka0:19092"
CONNECT_GROUP_ID: "connect"
CONNECT_REST_ADVERTISED_HOST_NAME: "connect"
CONNECT_PLUGIN_PATH: "/usr/share/java"
CONNECT_INTERNAL_KEY_CONVERTER: "org.apache.kafka.connect.json.JsonConverter"
CONNECT_INTERNAL_VALUE_CONVERTER: "org.apache.kafka.connect.json.JsonConverter"
CONNECT_KEY_CONVERTER: "io.confluent.connect.avro.AvroConverter"
CONNECT_KEY_CONVERTER_SCHEMA_REGISTRY_URL: "http://schema-registry:8081"
CONNECT_VALUE_CONVERTER: "io.confluent.connect.avro.AvroConverter"
CONNECT_VALUE_CONVERTER_SCHEMA_REGISTRY_URL: "http://schema-registry:8081"
CONNECT_CONFIG_STORAGE_TOPIC: "connect-config"
CONNECT_OFFSET_STORAGE_TOPIC: "connect-offset"
CONNECT_STATUS_STORAGE_TOPIC: "connect-status"
CONNECT_CONFIG_STORAGE_REPLICATION_FACTOR: "1"
CONNECT_OFFSET_STORAGE_REPLICATION_FACTOR: "1"
CONNECT_STATUS_STORAGE_REPLICATION_FACTOR: "1"
depends_on:
- "kafka0"
- "schema-registry"
ksql:
image: confluentinc/cp-ksql-server:5.2.2
ports:
- "8088:8088"
environment:
KSQL_BOOTSTRAP_SERVERS: "PLAINTEXT://kafka0:19092"
KSQL_LISTENERS: "http://0.0.0.0:8088"
KSQL_KSQL_SERVICE_ID: "ksql_service_docker"
KSQL_KSQL_SCHEMA_REGISTRY_URL: "http://schema-registry:8081/"
depends_on:
- "kafka0"
- "schema-registry"
connect-ui:
image: landoop/kafka-connect-ui:0.9.7
ports:
- "8084:8084"
environment:
PORT: "8084"
PROXY: "true"
CONNECT_URL: "http://connect:8083"
depends_on:
- "connect"
topics-ui:
image: landoop/kafka-topics-ui:0.9.4
ports:
- "8085:8085"
environment:
PORT: "8085"
PROXY: "true"
KAFKA_REST_PROXY_URL: "http://rest-proxy:8082"
depends_on:
- "rest-proxy"
schema-registry-ui:
image: landoop/schema-registry-ui:0.9.5
ports:
- "8086:8086"
environment:
PORT: "8086"
PROXY: "true"
SCHEMAREGISTRY_URL: "http://schema-registry:8081/"
depends_on:
- "schema-registry"
postgres:
image: postgres:11
ports:
- "5432:5432"
environment:
POSTGRES_USER: "cta_admin"
POSTGRES_PASSWORD: "chicago"
POSTGRES_DB: "cta"
volumes:
- ./producers/data/cta_stations.csv:/tmp/cta_stations.csv
- ./load_stations.sql:/docker-entrypoint-initdb.d/load_stations.sql
所有其他系统连接正确,并且在放置所有docker-comment文件时没有记录错误。我尝试使用不同的端口,但没有运气。在我看来,docker主机和WSL主机的绑定有问题?
我想知道:
如何根据配置文件从Windows Chrome浏览器连接到localhost:8084中的服务。
似乎您没有粘贴docker compose的完整代码。yml
,我想是你原来的docker作曲。yml将docker与名为connect
的kafka容器链接或联网,因此您可以连接http://connect:8003
但由于kafka直接安装在Windows(主机服务器)中,因此应用程序容器(kafka connect)不知道该主机名为connect
您可以用windows IP地址替换connect
。
CONNECT_URL: "http://<your_windows_IP>:8083"
抱歉,WSL中的Docker不支持端口转发到Windows主机。也就是说,您必须从WSL会话启动浏览器,然后将GUI转发到Windows。
您不能使用Windows的常规Docker吗?
要运行测试文件,Flask应用程序需要连接到Redis。我尝试将这些URL用于redis主机,如localhost:6379,redis:6379,0.0.0.0:6379,但都没有用。他们都告诉我连接错误或连接拒绝。 知道如何从jenkins docker容器中连接到redis吗?
没问题,只需将Docker守护进程配置为使用。那么您就可以完全按照本指南的其余部分进行操作了。 如果您沿着这条路走下去,我强烈建议您使用VMware Player滚动您自己的VM,而不是使用Docker工具箱,因为VirtualBox有疯狂的edge case共享文件夹错误,在某个时候会毁了您的生活。别担心,VMware播放器是免费的。只需谷歌如何在VMware Player上设置Ubuntu16
我在docker容器中的服务器上有Postgresql。如何从外部连接到它,即从本地计算机连接到它?我应该应用什么设置来允许它?
我的docker版本是1.13.1。我正试图从我的docker容器连接到redis-server,但我遇到了拒绝连接的错误。详细的日志如下: 原因:redis.clients.jedis.exceptions.jedisconnectionException:java.net.Connection:redis.clients.jedis.Connection(Connection.java:207
问题内容: Docker容器可以通过哪个IP地址连接到Windows版Docker(在Windows 10上)上的主机?您如何找到此IP地址? 例如:您有一个服务在Windows 10计算机上的端口1234上运行。容器中的程序必须访问此服务。程序应使用哪个IP地址连接到主机? 问题答案: 简短的回答 :在大多数情况下,您需要 10.0.75.1 。 在适用于Windows的Docker中,容器通过
docker容器可以在哪个IP地址上连接到它在docker for Windows(在Windows 10上)上的主机?如何找到这个IP地址?