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:
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:
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:
You can find your userid on your account profile.
The following example shows how to connect an apache container to a mysql container by making use of sloppy’s FQDN feature.
- WORDPRESS_DB_HOST: "mysql.backend.wordpress"
- WORDPRESS_DB_USER: "a-user"
- WORDPRESS_DB_PASSWORD: "secret"
- path: "/var/www/html"
- MYSQL_ROOT_PASSWORD: "supersecret"
- MYSQL_USER: "a-user"
- MYSQL_PASSWORD: "secret"
- MYSQL_DATABASE: "wordpress"
- path: "/var/lib/mysql"
About this example
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.
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:
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.