Connecting to Docker containers

Modified: 08 Sep 2022 04:28 UTC

Docker containers typically don't run an SSH daemon, but there are still a number of ways to connect to Docker containers to run software inside them or copy files out of them. Before attempting any of these, be sure your Docker environment is setup to connect to the Triton Docker endpoint

Shell access

While SSH access is not typically available, it's possible to use triton-docker exec interactively to start a shell, allowing you to run see the state of a running container and execute arbitrary applications.

Generically, this looks like this:

triton-docker exec -it <container_name_or_uuid> <shell_command>

If you're already running an Ubuntu container named "anxious_albert," then you can start bash in it with the following:

triton-docker exec -it anxious_albert bash

Some containers don't have bash in the path. Consider trying /bin/bash or /bin/shin case of trouble.

Copying files

It's possible to copy files out of a running Docker container using triton-docker cp (learn about options for docker cp). To copy a file from a running Ubuntu container named "anxious_albert," use a command similar to the following:

triton-docker cp anxious_albert:/root/myfile.txt .