Linking containers.

648    Asked by JanFerguson in Devops , Asked on Nov 28, 2019
Answered by Jan Ferguson

 More than one containers can be linked in docker to achieve communication b/w them.

For eg - If you have apache installed in container 1 and php-mysql in container 2 then both of these can be linked together to achieve a full LAMP stack architecture.

To link containers use below command

docker run -it --name container 2 --link container 1 -d

and both the containers will be linked together.

Also, containers can be linked via compose file also.

“links” parameter can be used with container name within compose file to link the containers straightaway.



Your Answer

Interviews

Parent Categories