Managing Docker With Shipyard API By Using Python Or Curl

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

Installing and managing Docker by Using the Shipyard API’s

There are many options to manage Docker. Below I will show you how to use Shipyard to manage your Docker environment

One of the great things about Shipyard is the web Interface, while that is true(and I will show that too). but this article is mainly focused on the befits and strength of using the API’s .

Installing Shipyard

First we need to install Shipyard. The process is rather simple, you can do it manually (which I will go through below), or full automated.

Installing Shipyard – fully automated

To quickly get up and running, install Shipyard fully automated, just run the below.
Note: There are a few options you can specify like TLS,etc.., for full details, please check the shipyard website

Installing Shipyard – manual method

Note: If you installed Shipyard the fully automated way, you can just skip this section.
The process below installs Shipyard in to your regular Docker (Swarm) environment.
Note: The process is almost identical to the process on the shipyard web site, with a few miner modifications which I will outline below.

The below docker run will install the Datastore, this is the database (Rethink DB) which stores all Shipyard activity.

Note: I added the port 49153 with the line -p 49153:8080, to expose the Rethink DB port. The reason for this was, to be able to explore the Rethink DB web UI, screen captures are below.

Shipyard RethinkDB – Main Screen
Shipyard RethinkDB - Main Screen
Shipyard Server Overview
Shipyard Server Overview

Next, we need to install the Discovery to enable Swarm leader elections.

You might also need to install the Proxy, this is a lightweight container that simply forwards requests from TCP to the Unix socket that Docker listens on.

Next, we need to install the Swarm Manager and Swarm agent.

Finally, we need to install the Shipyard controller.

Once completed we can now test to make sure shipyard is up and running, by going to.

The default login is admin and password is shipyard, please make sure to change the password once you login.

Managing Docker With Shipyard

Once Shipyard is up and running, it will auto-discover all your Docker instances, images, etc… You can manage most of your Docker environment form with-in the Web UI, or by using the API’s.
Note: Shipyard also has the option to be managed with the Shipyard CLI, by connecting to the Shipyard-Docker container.

Managing By Using the Web UI

To manager Docker with the shipyard web UI, just login to the web UI(in our case by going to port 8080).
Using the Web UI is quite simple, I will show a few examples below.
Shipyard login screen
Shipyard login screen
Shipyard Deploy – Options
Shipyard Container Stats
Shipyard Container Stats
Shipyard Container Stats
Shipyard Pulling Images

Managing Shipyard By Using the API’s

Shipyard has a simple API which is great to manage docker.
The example below uses Curl to create / add a new account to the system, by using the Shipyard API’s.
Below is a simple shell script to add a new account.
Note: Make sure to change the account names to your desire.

The next example lists all system accounts(including the newly created account).
Just added the below code to end of the above script.

To get a list of all roles.
Just added the below code to end of the above script.

Shipyard API – Python example
The example below, uses Python to list all accounts in the system.
Note: Replace username and password, with the account used to authenticate to the system.

To list all roles in the system, just replace the code on line 34, like the below.

Example of the Python script output of account listing.

Note: The Python script can easily be extended with additional functionality, helping in fully automate your Docker DevOps life-cycle.

In the Shipyard UI, you can also see the elik account created. this was created by running the Python script (using the reset API’s).

You can also see in the Web UI > Events. all API’s that ran in the past, for example the creation of the elik Account (screen capture below).

In summery, using Shipyard is a great and simple way to manage Docker. however, there are a list of yet desirable / noticeable missing features.

I will list some of them below.

  1. Using a Dockerfile by API
  2. Using a dokcer-compose.yml by API
  3. Intergeneration with a cloud provider, like AWS, GCP, Azure, etc…

What tools/programs are you using to manage Docker API’s?

You might also like
Managing Docker Using Docker-Compose to Create Multi-Container Docker Applications
Using ZFS For The Docker COW Storage Layer(s) In Ubuntu 17.04
Gotchas / Tips Creating Your Own Private Docker Registry With Self Signed Certificate
Using Chef Kitchen / Docker Build Behind a Corporate Proxy or Firewall

Leave a Reply

Notify of