How to Connect to Your Docker Container Inside Jelastic Cloud

DZone 's Guide to

How to Connect to Your Docker Container Inside Jelastic Cloud

Using Jelastic? Here are three ways you can connect your Docker container to the outside world.

· Cloud Zone ·
Free Resource

Docker container integration within Jelastic Cloud has become one of the most important and demanded services a platform can offer. And striving to help you to get the  most from this technology, we are regularly providing the related guides and tips.

As you've probably guessed from the title, today we'll try to fully observe and explain the ways of connecting to your Docker container at Jelastic, considering both internal and external possibilities.Connect to Docker in Jelastic

So, if you are just learning how to work with your Docker-based application or have met any difficulties while hosting it at Jelastic, the guide below will help you to get started. Within it, we'll show you where to find the very basic container information that is required for connection and a few quick tips on how this operation can be actually performed.

Each Docker container at Jelastic automatically gets a unique internal domain name and internal IP address right after creation. These ones can be used to access containers in confines of a single Cloud, i.e. to connect them with each other via the platform's internal network.

1. The very first option you need to consider in case you have to set up an interconnection between your containers is the embedded functionality of Docker's linking. It allows you to connect containers from different layers within a single environment to securely transfer environment variable information from a source Docker image to the recipient without exposing any ports externally.

For that, you just need to select the required layer and specify an alias for the connection denomination (all of the appropriate variables should get the corresponding prefix):Docker layer setting in Jelastic

Don't forget to Save and Apply the changes you’ve made.

After that, you may refer to the variables section of your Docker container settings and adjust any of them separately as needed. From here on out, changing the environment variable's value for a container that is already linked to another one will also cause an automatic update in the container this link was applied to.

2. In case you need to establish an internal connection of another type (i.e. which requires some manual adjustments via the configuration files), you'll need to know the exact container domain name or IP address it can be accessed via the platform's internal network.

The appropriate information can be obtained in two ways:

  • Through the email notification you receive after environment creation. The corresponding internal domain name and IP address are to be listed within the section with container admin data:

Access to Docker in Jelastic

Here, the container's domain name is shown at the Access URL string and its internal IP address is shown in the IP line below.

  • At the Jelastic dashboard, the same data can be found in the following ways:

– Click the open in browser button next to the Docker container you're interested in for the required node to be opened in the new browser tab. This way, you can easily copy its domain from the address bar.

Or, just right-click on the domain string under the environment name (circled below) and copy the provided link.

Open in browser in Jelastic– The internal IP address of the node can be viewed by expanding the "additionally" list for the required container, as it is shown in the image below.

IP address in Jelastic

This way, the retrieved information can be used to establish an internal connection to your Docker containers at Jelastic.

In order to access your Docker container from outside a platform, such as from the Internet, Jelastic offers the following solutions:

1. If your service or application running within a Docker container listens to the 80th port, then it will be automatically exposed to external networks (over the assigned domain name) via the Jelastic Shared Load Balancer.Open in Browser Jelastic

In this case, you just need to click "Open in browser" for the corresponding node to launch it (this option works for HTTP connections).

Note: In case your Docker container does not have an  external IP attached, Jelastic performs an  automatic port redirect . This means that if an application listens to a custom port on TCP level, Jelastic will try to automatically detect it and forward all the incoming requests to this port number. As a result, in most cases, your Dockerized app or service will become available over the Internet in the corresponding node's domain right after creation. However, in case you'd like to prohibit such a possibility, you may declare the corresponding rules within your container's  firewall settings .

2. For more complex implementations, Jelastic provides special endpoints functionality (available within the same-named section of any environment's Settings):Docker endpoints in Jelastic

It allows you to expose the required private port on your container through the randomly chosen public port at the Jelastic Shared Load Balancer, so it can be accessed via the provided Access URL.

3. And the last option, which grants the most freedom (allowing you, for example, to secure your connection with Custom SSL, get rid of the limitation on the number of simultaneous connections, etc) is attaching a public IP address to your Docker container.Jelastic Public IP address

With it, your app can be configured to listen to any port you need and, in such a way, become accessible to the external network.

While enabling the public IP option, please  pay attention that it's a paid add-on (the exact cost for its usage can be seen upon hovering over the price widget on the right side of your topology wizard or through navigating to  Quotas & Pricing  > Pricing > Options tab).

That's all for now! Feel free to leverage the most suitable connection option while working with your Docker containers. And as usual, we're always glad to provide you with any required technical assistance at Stackoverflow in case you have some questions left.

Still don't have an account? Register for free at any of our partners' platforms within Jelastic Cloud Union and experience the advantages first hand!

container ,docker ,jelastic

Published at DZone with permission of Tetiana Markova , DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}