https://docs.docker.com/desktop/windows/networking/

 

Networking features in Docker Desktop for Windows

 

docs.docker.com

Features

Port Mapping: -p HOST_PORT:CLIENT_PORT

$ docker run -p 8000:80 -d nginx

connections to localhost:8000 are sent to port 80 in the container.

 

Known limitations, use cases, and workarounds

There is no docker0 bridge on Windows

 

I cannot ping my containers

 

Per-container IP addressing is not possible

 

Use cases and workarounds

I want to connect from a container to a service on the host

The host has a changing IP address (or none if you have no network access).

We recommend that you connect to the special DNS name host.docker.internal

which resolves to the internal IP address used by the host.

This is for development purpose and will not work in a production environment outside of Docker Desktop for Windows.

 

You can also reach the gateway using gateway.docker.internal.

 

Example:

1. Run the following command to start a simple HTTP server on port 8000.

python -m http.server 8000

2. Now, run a container, install curl, and try to connect to the host using the following commands:

$ docker run --rm -it alpine sh
# apk add curl
# curl http://gateway.docker.internal:8000
# exit

curl http://host.docker.internal:8000
curl http://gateway.docker.internal:8000

I want to connect to a container from Windows

Port forwarding works for localhost; --publish, -p, or -P all work.

Ports exposed from Linux are forwarded to the host.

Our current recommendation is to publish a port, or to connect from another container.

This is what you need to do even on Linux if the container is on an overlay network, not a bridge network, as these are not routed.

For example, to run an nginx webserver:

$ docker run -d -p 80:80 --name webserver nginx

To clarify the syntax, the following two commands both publish container's port 80 to host's port 8000:

$ docker run --publish 8000:80 --name webserver nginx

$ docker run -p 8000:80 --name webserver nginx

To publish all ports, use the -P flag.

For example, the following command starts a container (in detached mode) and the -P flag publishes all exposed ports of the container to random ports on the host.

$ docker run -d -P --name webserver nginx

 

'OS > Docker' 카테고리의 다른 글

Docker Desktop Tips  (0) 2021.10.12

docker 설치 및 확인

https://docs.confluent.io/4.0.0/installation/docker/docs/quickstart.html

 

Docker Quick Start | Confluent Platform 4.0.0

Important You are viewing documentation for an older version of Confluent Platform. For the latest, click here. Docker Quick Start This quick start provides a basic guide for deploying a Kafka cluster along with all Confluent Platform components in your Do

docs.confluent.io

2. Clone the Confluent Platform Docker Images Github Repository.

...\confluent> git clone https://github.com/confluentinc/cp-docker-images

3. Start the ZooKeeper and Kafka containers in detached mode (-d).

Run this comand from the directory that contains the docker-compose.yml file.

> cd <path-to-cp-docker-images>/examples/kafka-single-node/
> docker-compose up -d

> docker-compose logs zookeeper | grep -i binding
> docker-compose logs kafka | grep -i started

 

 

 


아래는 이전에 했던 방법.

 

docker-compose 이용

https://github.com/conduktor/kafka-stack-docker-compose

 

GitHub - conduktor/kafka-stack-docker-compose: docker compose files to create a fully working kafka stack

docker compose files to create a fully working kafka stack - GitHub - conduktor/kafka-stack-docker-compose: docker compose files to create a fully working kafka stack

github.com

Dev Environments > Create

 

Enter the Git Repository

https://github.com/conduktor/kafka-stack-docker-compose.git

OPEN IN VSCODE

yml 파일 작성하기

zk-single-kafka-single.yml을 기반으로 ym-test-z1-k1.yml 작성

$ docker-compose -f ym-test-z1-k1.yml up

vscode ➜ /com.docker.devenvironments.code (master ✗) $ sudo chmod 666 /var/run/docker.sock
vscode ➜ /com.docker.devenvironments.code (master ✗) $ export DOCKER_HOST_IP=192.168.65.100
vscode ➜ /com.docker.devenvironments.code (master ✗) $ docker-compose -f ym-test-z1-k1.yml up
Starting comdockerdevenvironmentscode_zoo1_1 ... done
Starting comdockerdevenvironmentscode_kafka1_1 ... error

ERROR: for comdockerdevenvironmentscode_kafka1_1  Cannot start service kafka1: Ports are not available: listen tcp 0.0.0.0:9999: bind: An attempt was made to access a socket in a way forbidden by its access permissions.

ERROR: for kafka1  Cannot start service kafka1: Ports are not available: listen tcp 0.0.0.0:9999: bind: An attempt was made to access a socket in a way forbidden by its access permissions.
ERROR: Encountered errors while bringing up the project.

 

Docker subnet 설정

$ sudo chmod 666 /var/run/docker.sock
$ export DOCKER_HOST_IP=192.168.65.100
$ docker-compose -f zk-single-kafka-single.yml up

 

'OS > Windows' 카테고리의 다른 글

How to build the HackRF on Windows  (0) 2023.08.29

+ Recent posts