Docker-2:network containers

Source: Internet
Author: User
Tags docker run

Docker run-d-P--name web Training/webapp python app.py#-name means give the To-be-run container a name ' Web '.-p means Connect web to default network space BridgeDocker network Lsdocker run-ITD--name=networktest Ubuntu#container named Networktest from image Ubuntu have defaultly connected to bridgeDocker Network Inspect Bridgedocker network Create-D Bridge my-bridge-network#Create a new network space "my-bridge-network" with network Type "bridge", and the other type is "overlay".Docker Network Lsdocker network inspect my-bridge-Network Docker Run-D--network=my-bridge-network--name db Training/webapp#Run Container "db" and add it to my-bridge-networkDocker Inspect my-bridge-Networkdocker Inspect--format='{{json. Networksettings.networks}}'Db#Check the networking of container dbDocker Inspect--format='{{range. networksettings.networks}}{{. Ipaddress}}{{end}}'Db#Check the networking of container dbDocker run-d-P--name web Training/webapp python app.py#start a container web in net Space "bridge"Docker Inspect--format='{{range. networksettings.networks}}{{. Ipaddress}}{{end}}'Web#Check the networking of container webDockerexec-it DB Bash#run container db with bash cmd #in the container, we use ping ip_of_web, it fails for web are in bridge and DB is in My-bridge-network, eventhough both Web and DB containers is from the same imageDocker Network Connect My-bridge-network Web#Now Connect Web to My-bridge-network,docker networking allows attach a container to as many networks as you lik E.Dockerexec-it DB Bash#run container db with bash cmd, use ping web. Succeed cause web and DB is in the same network

Docker-2:network containers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.