Use Triton Docker on Cloudcontainers

Created by Vincent van Gelderen at 23-05-2018 14:09:52 +0200

To start using Docker together with cloudcontainers you will need to install the correct client environment. This is a how-to for Mac OS X users.

PREPARE KEYS

To start working with Docker on cloudcontainers you will need a public and private key. The steps below show how to create these using SSH.

Create new SSH key

$ ssh-keygen -t rsa -b 2048
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/fred/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/fred/.ssh/id_rsa.
Your public key has been saved in /Users/fred/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:QY70IGYN3O4DbDRrXzc0wKMQsOpkDzrYvWKgR53pb5s fred@intcorp.com
[...]

Upload public SSH key to cloudcontainers

From the top menu, click on your account name and select "Manage account". Click the tab "SSH keys" and review any existing keys. It is very common for keys to show more than once, as they are reported for every datacenter.

For "Key Name", enter a name for easy recognition in the future (an email address such as fred@intcorp.com is often a good choice).

For "Key Value", enter the contents of the id_rsa.pub that you just created. Click the button "Add new key", and review the new entries.

Basic steps to start working with Docker, if you are on Mac OS X.

  • ✴  Install Node JS

  • ✴  Install Trion CLI

  • ✴  Install Triton Docker CLI

    You will need Admin privileges to run various installers, and the ability to run installation scripts with 'sudo'.

    Install Node JS

    Download the LTS version of Node JS from https://nodejs.org/en/ and run the installer.

    $ node -v
    v8.11.2
    $ npm -v
    5.6.0

    Install Triton CLI

    Use standard NPM command to install the latest version of the Triton CLI.

    $ sudo npm install --unsafe-perm -g triton

Create a new profile

Use the triton command to save connection information as a new profile. You will need to supply the following information.

  • ✴  A short name to recognize the new profile.

  • ✴  URL for the datacenter you want to use.

  • ✴  Your account name.

  • ✴  The SSH key to make connections.

    $ triton profile create
    A profile name. A short string to identify this profile to the `triton` command.
    name: cloud1
    The CloudAPI endpoint URL.
    url: https://
    Your account login name.
    account: intcorp
    The fingerprint of the SSH key you want to use to authenticate with CloudAPI.
    Specify the fingerprint or the index of one of the found keys in the list
    below. If the key you want to use is not listed, make sure it is either saved
    in your SSH keys directory (~/.ssh) or loaded into your SSH agent.
    1. Fingerprint "8c:40:af:c0:a7:3f:b8:a0:32:74:44:b7:64:e7:95:d5" (2048-bit RSA)
       - in homedir: $HOME/.ssh/id_rsa (comment "fred@intcorp.com")
    keyId: 1
    Using key 1: 8c:40:af:c0:a7:3f:b8:a0:32:74:44:b7:64:e7:95:d5
    Saved profile "cloud1".
    # Docker setup
    This section will setup authentication to Triton DataCenter's Docker endpoint
    using your account and key information specified above. [...]
    Continue? [y/n] n

    The last question asks us if we immediately want to configure Docker settings. Answer no for the time being.

Use the new profile

Let us try a few Triton CLI commands to test the new setup.

$ triton profile get
$ triton info
$ triton ls

Set up Docker configuration

$ triton profile docker-setup

The configuration files that were just created will be needed for the next step.

Install Triton Docker CLIInstall CLI

Download the first install script and run it.

$ sudo bash --verbose -c 'curl --verbose --output /usr/local/bin/triton-docker \
https://raw.githubusercontent.com/joyent/triton-docker-cli/master/triton-docker'

$ sudo bash -c 'chmod +x /usr/local/bin/triton-docker'
$ sudo bash -c 'ln -Fs /usr/local/bin/triton-docker /usr/local/bin/triton-compose'$ sudo bash -c 'ln -Fs /usr/local/bin/triton-docker /usr/local/bin/triton-docker-install'

Now run the second part.

$ sudo triton-docker-install

Sanity checks

We are almost ready to start creating containers using Docker. Let us see if the commands below report on

  • ✴  Basic information about Docker

  • ✴  Versions on client and server

  • ✴  Previously created Docker containers

  • ✴  Network information
    No command should produce an error.

    $ triton-docker info
    $ triton-docker version
    $ triton-docker ps -a
    $ triton-docker network ls

CREATE DOCKER CONTAINERS

Web server 'nginx' can serve as a simple start. Let us use the 'run' command to start one. Among the options we provide,
✴ the flag -d tells Docker to detach the container, so our command prompt returns while the container keeps

running
✴ the flag -p 80 tells Docker to expose the port 80 for HTTP traffic
✴ the flag --name My-Fabric-Network tells Docker where to allocate a private IP address


$ triton-docker run -d -p 80 --network My-Fabric-Network --name webserver nginx
73c36e...
$ triton-docker inspect --format='{{.NetworkSettings.IPAddress}}' webserver
194.61.64.83

The second command reveals the IP address that was allocated to your new container. Copy and paste it in your browser, and you will see the "Welcome to nginx!" message as a greeting.
We can inspect the application's log files.
$ triton-docker logs -tf webserver

2018-05-22T08:19:10.409770000Z 127.0.0.2 - - [22/May/2018:08:19:10 +0000] "GET /
favicon.ico HTTP/1.1" 404 170 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:
60.0) Gecko/20100101 Firefox/60.0" "-"

Comments

Comments are turned off.