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

How to realize data transfer between Docker containers

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to achieve data transmission between Docker containers, I hope you will learn something after reading this article, let's discuss it together!

1. Copy the file from the container to the host.

At the host where you want to receive the file, run the following instructions

Docker cp container id:home/test .docker run-d-- name nginxtest-p 82:80 nginxcurl localhost:82// packaged image docker commit-a = "gym"-m = "add basic webapps app" 94b00b6f6172 tomcat_9.0:1.0// start running docker run-d-p 8080 run-- name tomcat01 tomcat// enters the container Open a new terminal (attach) docker exec-it id / bin/bash// file mount docker run-d-p 9999pur8080-v / root/test:/home-- name= "tomcat01" 1b6b1fe7261edocker run-it-v host directory: directory in the container-p host port: container port / / case metadata docker inspect 992cde01ffc5 persistence database docker run-- name some-mysql-e MYSQL_ROOT_PASSWORD=my-secret-pw-d mysql: view Port occupies netstat-tanlpkill Kill View History Container docker ps-as Delete all containers docker rm $(docker ps-aq) dockerfile create your own image [root@centos docker] # vim dockerfile [root@centos docker] # cat dockerfileFROM centosVOLUME ["volume01" "volume02"] CMD echo "- end---" CMD / bin/bash [root@centos docker] # docker build-f dockerfile-t gym/centos. Implement anonymous mount docker inspect mount using container data volume

Upload your own image to Aliyun

The network interconnection between containers should be the existence of docker0.

The technology used is evth-pair technology!

# We found that this container brings network cards in pairs. # evth-pair is a pair of virtual machine device interfaces, and they all appear in pairs, one end is connected to the protocol, and the other end is connected to each other. # because of this feature, veth-pair acts as a bridge between # openStac,Docker containers connecting various virtual network devices, and OVS connections are all using evth-pair technology.

You can ping each container through ip, but if it's a name, you can't use link.

After reading this article, I believe you have a certain understanding of "how to achieve data transmission between Docker containers". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

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

Development

Wechat

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

12
Report