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

Example Analysis of Docker Command

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Editor to share with you the example analysis of the Docker command, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Docker command

1. Command format:

Docker run-it-- name mydocker1 [image1] bash # individually named image1 as mydocker1

Docker run-it-- link mydocker1:mydocker1 [image2] bash connects two image so that image1 and image2 can communicate with each other

2. Command function:

Connect two container to communicate with each other

3. Command parameters:

-it-- name first name the first image1

-it-- link connects to the first image and can communicate with each other

4. Command example:

First open a window and enter the following command to open a docker window 1

[root@docker] # docker run-it-- name node1 node bash

Root@f2765d5fd9c8:/#

Open another window 2 again and enter the following command:

[root@docker] # docker run-it-- link node1:node1 node bash

Root@e85d11098482:/#

Enter the following command under the second docker window:

Root@e85d11098482:/# ping node1 shows that the ip address of node1 is 172.16.0.16

PING node1 (172.17.0.16): 56 data bytes

64 bytes from 172.17.0.16: icmp_seq=0 ttl=64 time=0.110 ms

64 bytes from 172.17.0.16: icmp_seq=1 ttl=64 time=0.073 ms

64 bytes from 172.17.0.16: icmp_seq=2 ttl=64 time=0.075 ms

64 bytes from 172.17.0.16: icmp_seq=3 ttl=64 time=0.094 ms

Cmurmuri-node1 ping statistics

4 packets transmitted, 4 packets received, 0 packet loss

Round-trip min/avg/max/stddev = 0.073 ms 0.088 ms 0.110 Compact

Enter the following command under the first docker window to see that the IP address of the window is the IP address of node1

Root@f2765d5fd9c8:/# ip addr

1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1

Link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

Inet 127.0.0.1/8 scope host lo

Valid_lft forever preferred_lft forever

Inet6:: 1/128 scope host

Valid_lft forever preferred_lft forever

34: eth0@if35: mtu 1500 qdisc noqueue state UP group default

Link/ether 02:42:ac:11:00:10 brd ff:ff:ff:ff:ff:ff

Inet 172.17.0.16/16 scope global eth0

Valid_lft forever preferred_lft forever

Inet6 fe80::42:acff:fe11:10/64 scope link

Valid_lft forever preferred_lft forever

The above is all the contents of the article "sample Analysis of Docker commands". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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