Linking containers in Docker

Linking containers in Docker 1

we deploy so many codes,scripts in different containers so to run some scripts we need to link to containers


docker run –-name <container2> –-link <conatiner1>:type –p <port>:80 –d <instancename>

for example, to run WordPress we need a database, so we pull WordPress image and MySQL image, these two will run on two containers .when we link these two containers, there is no need to provide database details while installing the WordPress

1.pull wordpress and mysql

docker pull mysql
docker pull wordpress

2.give an environment for MySQL

docker run –-name name1 –e MYSQL_ROOT_PASSWORD=password -d mysql:latest wordpress container

docker run –-name name2 –-link name1:mysql–p 8080:80 –d wordpress your ip with port 8080

Default image
Vishal Devxo
Vishal Devxo is a DevOps engineer and a Backend developer, he spends all his time for creating good tutorials with better visuals and blogging, developed some projects based on Python-Django, some hacking modules and scripts in python