Ryan Jones bio photo

Ryan Jones

Ryan is head of Foundational Services, developing applications and microservices in Node.js and Java Spring Boot, and managing our Docker Swarm Stack with Portainer, Traefik, Nginx, Elasticsearch and more.

Email

In this post, I’ll use a Jupyter Notebook to spin up a local Docker Swarm running a private Docker Registry, a Registry Frontend, Traefik and Portainer.

Check out this recording of my talk (25 min)!

Background

Docker has been a buzzword around software development teams for several years already, and the buzz has continued to grow stronger and louder. This has certainly brought much beloved excitement to the community, but it has also created a lot of noise. It can be challenging for veterans to sift through available options, and daunting for new-comers to even know where to start (hint: start here).

Docker has made testing and evaluating applications easier and faster than ever before! While it is simple to spin up a single container, sometimes a full stack is required. For example, you may want to test a build or versioning strategy without pushing to your official registry. You may want to test routing changes with your favorite reverse-proxy. You may want to introduce global logging. Wouldn’t it be great if you could do all of this locally? And without breaking a sweat?

At Conversant, we’re using Docker from early development, to QA, and even production. We’ve built up our stack around Docker Swarm and embraced Docker CE and many other open source solutions: Portainer, Traefik, Docker Registry, Elasticsearch and more. We also believe in giving back. We hope you enjoy Docker Swarm Local!

Getting Started

Note: This demo assumes Mac OS. Watch the repo and/or contribute for Windows or Ubuntu support.

Cloning the Repo

To get started, head over to the Github page where you can browse source code and clone the Repo:

https://github.com/conversant/docker-swarm-local

Installing Jupyter

If you’re new to Jupyter, head over to the install page.

The demo is written as a Bash notebook, so we’ll need to install the Bash Kernel as described here.

Run the following command to install the bash kernel for Jupyter:

pip install bash_kernel
python -m bash_kernel.install

Running Jupyter

In a new terminal from the root of the project directory, run the following command:

jupyter notebook

Jupyter will launch in a browser and you’ll see a file named jupyter-notebook.ipynb:

Select it and follow along as we run each step in the notebook.

Following Along

If you’re new to Jupyter Notebooks, please check out their Quick Start Guide.

If at any time you wish to reset the notebook, simply select “Kernel” then “Restart & Clear Output”:

Click the Run button in the Notebook to advance through the commands…

The first steps in our notebook sets up a couple of environment variables:

  • $USER: defaults to the current user
  • $HOST: name of the virtual host we’ll create next

We’ll now create our first host using docker machine. It will be given the name from $HOST above, and we’ll grab its IP for use later…

We’ll continue to initialize the swarm on our new host, deploy stacks for Docker Registry, Traefik and more, push images to our private registry, and spin up a couple more nodes and register those with our swarm.

Now check out my video where I continue to walk through each step in detail! By the end, you too will have a local Docker Swarm running with Traefik, Portainer, and your own private Docker Registry.