SiteHost

Connecting to a Container

Containers are able to talk to each other, this is done using a private network between the containers. To make this easier to use, there are host definitions for the linked containers. The name of the container will be the same as the host you connect to and these hosts can be used to connect to the different containers.

For example, from a shell, you are able to connect to mysql using the following:

$ mysql -u example -h mysqlhost -p

Examples

Here are some examples on how to connect to various containers from a shell.

Redis

Let's say you have a Redis 4 container, and you want to connect to it. First you need to make sure that the SSH user only has access to the Redis 4 container, otherwise you wont have access to commands such as redis-cli.

Note: In this example we assume the container hostname is redis8d61ae7f4ad53

To connect, we shell in and run the following command:

$ redis-cli -h redis8d61ae7f4ad53
redis8d61ae7f4ad53:6379>

Postgres

Once again we are assuming the container hostname is pgf4c7c088a63167, and as described above, the SSH user only has access to the Postgres 9.6 container.

Note: The default password for the postgres user is 'password'

To connect, we shell in and run the following command:

$ psql -U postgres -h pgf4c7c088a63167
Password for user postgres: 
psql (9.6.10)
Type "help" for help.

postgres=#

For more information on how SSH privileges work, please refer to our article on SSH/SFTP user privileges.