Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of interconnecting Docker port mapping with containers

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "what is the method of Docker port mapping and container interconnection". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the method of Docker port mapping and container interconnection".

A new mydocker container is established, in which a mysql is installed and started. It is hoped that the container's mysql database can be accessed directly through centos.

Method one

[root@mysql01 ~] # docker inspect mydocker | grep-I ipaddre

"SecondaryIPAddresses": null

"IPAddress": "172.17.0.3"

"IPAddress": "172.17.0.3"

Configure forwarding:

[root@mysql01] # iptables-t nat-A DOCKER-p tcp-- dport 3388-j DNAT-- to-destination 172.17.0.3

Check:

[root@mysql01 ~] # docker port mydocker

[root@mysql01 ~] # netstat-nputl | grep-I 3388

[root@mysql01 ~] iptables-t nat-L-n (Port forwarding can be viewed in this way)

Method 2:

1. Save the mydocker container as a mirror first

Docker commit mydocker myimages

two。 Then restart a container mysql5.6.24 on the myimages image and specify the port mapping

Docker run-d-name mysql5.6.24-p 3366 it myimages 3306-it myimages / bin/bash

3. Check

[root@mysql01 ~] # netstat-nputl | grep-I 3366

Tcp6 0 0: 3366: * LISTEN 17673

[root@mysql01 ~] # docker port mysql5.6.24

3306/tcp-> 0.0.0.0pur3366

Thank you for reading, the above is the content of "what is the method of Docker port mapping and container interconnection". After the study of this article, I believe you have a deeper understanding of what is the method of Docker port mapping and container interconnection, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report