Docker container Link

Source: Internet
Author: User
Tags docker ps

Container and container communicate with each other. The official name is linking containers together!

The most common is to run a web iner and a DB container to link the Web container to the DB container;


A network channel (BRIDGE) is established between two containers through link, and DB iner only needs to know the alias and open port number of the previous container;


Example:

Start a DB container first:

$ sudo docker run -d --name db training/postgres

Then start Web Container link dB container

$ sudo docker run -d -P --name web --link db:db training/webapp python app.py

Note -- Link flag takes the form:

--link name:alias

View through docker PS:

$ docker psCONTAINER ID  IMAGE                     COMMAND               CREATED             STATUS             PORTS                    NAMES349169744e49  training/postgres:latest  su postgres -c ‘/usr  About a minute ago  Up About a minute  5432/tcp                 db, web/dbaed84ee21bde  training/webapp:latest    python app.py         16 hours ago        Up 2 minutes       0.0.0.0:49154->5000/tcp  web

The DB container Web/DB shows that the Web container has been linked to the DB container.




This article is from the "Siberian wolf" blog, please be sure to keep this source http://kernal.blog.51cto.com/8136890/1538610

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.