How to Link an External Application or Non-Docker Container to Docker

Hi,

How to link an application outside the Docker?

I’m trying to link my Oracle DB on my local machine and Kafka on my Tencent Cloud.

This is the command that I’m trying to do:
“docker run -it --rm --name connect -p 8083:8083
-e GROUP_ID=1
-e CONFIG_STORAGE_TOPIC=my_connect_configs
-e OFFSET_STORAGE_TOPIC=my_connect_offsets
-e STATUS_STORAGE_TOPIC=my_connect_statuses
–link kafka:kafka
–link dbz_oracle21:dbz_oracle21
-v /path/to/ojdbc8.jar:/kafka/libs/ojdbc8.jar
quay.io/debezium/connect:latest

I’m having problems on “–link” argument.

Thank you in advance for your response! :slight_smile:

Hello @jmourning ,

The --link argument is a legacy feature and it’s generally recommended to use user-defined networks for container communication in Docker. The --link flag might cause issues because it’s deprecated and may not work as expected with newer versions of Docker.

Create a User-Defined Network, Connect Your Containers to the Network For the containers that you want to communicate with each other, make sure to connect them to the network you’ve created.

docker run --name kafka -d --network mynetwork kafka-image
docker run --name dbz_oracle21 -d --network mynetwork oracle-image

Now, when you run your application container, you don’t need to use the --link argument.

docker run -it --rm --name connect -p 8083:8083 \
-e GROUP_ID=1 \
-e CONFIG_STORAGE_TOPIC=my_connect_configs \
-e OFFSET_STORAGE_TOPIC=my_connect_offsets \
-e STATUS_STORAGE_TOPIC=my_connect_statuses \
-v /path/to/ojdbc8.jar:/kafka/libs/ojdbc8.jar \
--network mynetwork \
quay.io/debezium/connect:latest

By using a user-defined network, your containers can communicate with each other using their container names as hostnames. This method is more robust and flexible compared to the old --link approach.

Remember to replace kafka-image and oracle-image with the actual images you are using for Kafka and Oracle DB. Also, ensure that your Oracle DB and Kafka are configured to accept connections from the Docker network.

Best Regards,

What are you trying to do? You can only link local containers (doc).

You can connect to other external services using their domain name or IP address.