Skip to content

Connecting to a Container

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

Examples

MySQL

From a shell, you are able to connect to MySQL using the following:

$ mysql -u example -h mysqlhost -p

Redis

Because of the way SSH user privileges work, you’ll need an SSH user that only has access to the Redis container. Then you’ll have access to commands such as redis-cli.

SSH into the container and run the command below. Edit the code to replace redis1a23bc4d5ef67 with your container name:

$ redis-cli -h redis1a23bc4d5ef67
redis1a23bc4d5ef67:6379>

Postgres

Because of the way SSH user privileges work, you’ll need an SSH user that only has access to the Postgres container.

Use the code below as an example. Replace pgf1a2b345c67890 with your container name, and make sure you know your Postgres password (the default is password):

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