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

Windows 기능 설정

가상화 지원 확인

System requirements

WSL 2 backend / Hyper-V backend and Windows Containers

  • Enable the WSL 2 feature on Windows.
  • Hyper-V and Containers Windows features must be enabled.
  • The following H/W prerequisites are required to successfully run WSL 2/Client Hyper-V on Windows 10:
    • 64-bit processor with Second Level Address Translation (SLAT)
    • 4GB system RAM
    • BIOS-level hardware virtualization support must be enabled in the BOIS settings.
  • Download and install the Linux kernel update package.

 

  •  

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

Networking features in Docker Desktop for Windows  (0) 2021.10.13

커널에 대한 정보

uname -a

OS 버전에 대한 정보

:~$ cat /etc/issue
Ubuntu 20.04.3 LTS \n \l

:~$ cat /etc/*release*
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.3 LTS"
NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.3 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

:~$ getconf LONG_BIT
64

:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.3 LTS
Release:        20.04
Codename:       focal

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

CMake Install  (0) 2022.10.01
VSCode: ssh로 접근해서 편집된 파일 저장 시 permission 문제  (0) 2022.08.22
glib/streamer install  (0) 2021.11.15
WSL2에서 GUI 사용하기  (0) 2021.10.19
Installing Linux Developer Tools  (0) 2021.10.19

+ Recent posts