When you are hosting with us, each of your projects is living in it’s own network space. While all the services and apps in your project can talk to each other, they are separated securely from all of the other projects in our Docker hosting cloud.

sloppy makes your applications (containers) talk with each other: Every container inside of a project gets a fully qualified domain name (FQDN), structured like this:

app.service.project 

This internal FQDN can be used to link or connect containers with each other. Let’s say you have set up a project named wordpress with a service called backend, that is holding an application by the name of mysql. Then you make this container accessible for other containers using the following FQDN:

mysql.backend.wordpress

The full FQDN also includes your userid, but we automatically add this for you when using environment variables plus the domain suffix .node.intern.

You can find the FQDN for each app under Settings => Advanced:

Note: If you are using configuration files to connect your containers, you need to add your userid yourself to the FQDN. Let’s say your userid is john, the FQDN for the example above would be:

mysql.backend.wordpress.john.node.intern

You can find your userid on your account profile.
 

Example YML

The following example shows how to connect an apache container to a mysql container by making use of sloppy’s FQDN feature.

version: "v1"
project: "wordpress"
services:
  frontend:
    apache:
      image: "wordpress:4.7.4"
      instances: 1
      mem: 512
      domain: "$URI"
      port: 80
      env:
        - WORDPRESS_DB_HOST: "mysql.backend.wordpress"
        - WORDPRESS_DB_USER: "a-user"
        - WORDPRESS_DB_PASSWORD: "secret"
      volumes:
        - path: "/var/www/html"
          size: "8GB"
      dependencies:
        - "../backend/mysql"
  backend:
    mysql:
      image: "mysql:8.0.0"
      instances: 1
      mem: 512
      env:
        - MYSQL_ROOT_PASSWORD: "supersecret"
        - MYSQL_USER: "a-user"
        - MYSQL_PASSWORD: "secret"
        - MYSQL_DATABASE: "wordpress"
      volumes:
        - path: "/var/lib/mysql"
          size: "8GB"

 

About this example

This sloppy.yml is making use of the the official WordPress and MySQL Docker images. So if you run it using the sloppy start command, it might take a moment to download those images from the Docker Hub.

The env key is used to configure the environment variables embedded in those images to set up WordPress and the MySQL server, and create a database for WordPress.

Talking about linking/connecting containers, we are using the FQDN feature of sloppy to set WORDPRESS_DB_HOST. This environment variable is expecting the path to the MySQL database used for WordPress. In the example above it is:

mysql.backend.wordpress

Thanks to the FQDN provided to the WordPress container in the frontend service of the project, it is able to directly connect to the MySQL container in the project’s backend service.

| For more information about environment variables, check the Docker User Guide and the section on environment variables in the sloppy documentation.

| To learn more about connecting containers using the FQDN feature, also have a look at our node.js tutorial where we connect a node.js container with a MongoDB container.

Did this answer your question?