Networking

How networking in DECK works and how to use it?

Under the hood, DECK utilizes docker’s networking features to connect a stack’s network with a container

Out of the box, each container is interconnected and can communicate with each other inside a stack, this is achieved by using a bridge network in docker.

For instance, in a LAMP stack PHP can connect to both Apache and MySQL inside a stack.

However, in a certain situation, you might want to connect a container within a stack to another container in a different stack. Consider these examples below …

  • Nginx/PHP stack needs to connect a standalone MongoDB stack
  • Or, an Nginx/PHP stack needs to do API request to another stack’s webserver

For the above to work correctly, you need to configure networks using the Networking feature in DECK.

To configure go to Networks on the DECK side menu, considering example #1 above, select the network of MongoDB stack and select the container of php-fpm and hit Attach.

The reason above for choosing php-fpm instead of Nginx is because the former connects with MongoDB from your PHP code, the latter serves as gateway for the output from php-fpm

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *