简体   繁体   中英

How Can I Run the python programs on Docker using active containers with the VS Code?

I want to run Kafka producer / consumer and connect them to the Broker using VS Code.

1- I have already run a Kafka Broker with the docker-compose, with an active Kafka container. How can I use the Kafka container without installing it locally ?

I have installed the kafka library on my local machine, and everything worked perfectly..

Expected: Using the Kafka container instead of the local lib.

I'm answering this with the assumption that when you say you machine, you're referring to your local machine (I would comment directly on your question ask for clarification, but I don't have enough rep yet). Installing a library locally allows for it to work locally, but not in other environments. So you need to install the Kafka library within the environment you're targeting, too.

I don't know kafka , In my experience, I use docker-compose to build the wordpress and mysql , which wordpress is based on mysql , which is explicitly stated in their docker-compose.yml . When I run docker-compose up -d , the wordpress is connected to the mysql container instead of mysql on my machine.

How can I use the Kafka container without installing it locally ?

Not clear what "it" is... The Docker image? That's not how Docker works.

You need to install pull the Docker image locally in order to use it

I have installed the kafka library on my local machine

I assume that you mean something downloaded from kafka.apache.org? If that's the case, no, you don't need that for Python

You will instead have to pip install some Kafka Python package and write code to communicate to the Kafka container

It sounds like you want to connect to a container or a remote machine using VS Code. Please see the instructions for remote development in VS Code on how to remotely connect to containers or machines via SSH.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM