• Stars
    star
    3,250
  • Rank 13,811 (Top 0.3 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created over 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A visualizer for Docker Swarm Mode using the Docker Remote API, Node.JS, and D3

Sample image of  nodes with data

Docker Swarm Visualizer

*** note *** This only works with Docker Swarm Mode in Docker Engine 1.12.0 and later. It does not work with the separate Docker Swarm project

Also this is a sample app meant for learning Docker. Running this app in production is insecure and should be avoided. If you want to run it in production you must take all security precautions, and in particular Protect the Docker daemon socket with SSL.

This project was originally created by Francisco Miranda for the 2015 DockerCon EU keynote. It was adapted to be used for the 2016 DockerCon US keynote showcasing Docker swarm mode. Since then the community has generously contributed many updates. Thanks to all the contributors, and a special thanks to @DovAmir and @alexellis for their big contributions.

Demo container that displays Docker services running on a Docker Swarm in a diagram.

This works only with Docker swarm mode which was introduced in Docker 1.12. These instructions presume you are running on the master node and you already have a Swarm running.

Each node in the swarm will show all tasks running on it. When a service goes down it'll be removed. When a node goes down it won't, instead the circle at the top will turn red to indicate it went down. Tasks will be removed. Occasionally the Remote API will return incomplete data, for instance the node can be missing a name. The next time info for that node is pulled, the name will update.

To run:

$ docker run -it -d -p 8080:8080 -v /var/run/docker.sock:/var/run/docker.sock dockersamples/visualizer

If port 8080 is already in use on your host, you can specify e.g. -p [YOURPORT]:8080 instead. Example:

$ docker run -it -d -p 5000:8080 -v /var/run/docker.sock:/var/run/docker.sock dockersamples/visualizer

To run with a different context root (useful when running behind an external load balancer):

$ docker run -it -d -e CTX_ROOT=/visualizer -v /var/run/docker.sock:/var/run/docker.sock dockersamples/visualizer

To run in a docker swarm:

$ docker service create \
  --name=viz \
  --publish=8080:8080/tcp \
  --constraint=node.role==manager \
  --mount=type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \
  dockersamples/visualizer

Supported architectures

The main dockersamples/visualizer image supports linux/amd64.

For armhf, there is a pre-built image available. See Running on ARM.

For Windows, there is a separate Dockerfile.windows and image. See Running on Windows.

Missing your architecture? See Building a custom image.

Running on ARM

@alexellisuk has pushed an image to the Docker Hub as alexellis2/visualizer-arm:latest it will run the code on an ARMv6 or ARMv7 device such as the Raspberry Pi.

$ docker service create \
  --name=viz \
  --publish=8080:8080/tcp \
  --constraint=node.role==manager \
  --mount=type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \
  alexellis2/visualizer-arm:latest
  • Update/rebuild the image:

If you would like to build the image from source run the following command:

$ docker build -t visualizer-arm:latest .

Make sure you do this on a Raspberry Pi directly.

View on Docker Hub

Running on Windows

@StefanScherer has pushed an image to the Docker Hub as stefanscherer/visualizer-windows:latest it will run the code in a Windows nanoserver container.

If you would like to build the image from source run the following command:

$ docker build -f Dockerfile.windows -t visualizer-windows:latest .

On Windows you cannot use -v to bind mount the named pipe into the container. Your Docker engine has to listen to a TCP port, eg. 2375 and you have to set the DOCKER_HOST environment variable running the container.

$ip=(Get-NetIPAddress -AddressFamily IPv4 `
   | Where-Object -FilterScript { $_.InterfaceAlias -Eq "vEthernet (HNS Internal NIC)" } `
   ).IPAddress

docker run -d -p 8080:8080 -e DOCKER_HOST=${ip}:2375 --name=visualizer stefanscherer/visualizer-windows

Connect to a TLS secured Docker engine

To work with a TLS secured Docker engine on Windows, set the environment variable DOCKER_TLS_VERIFY and bind mount the TLS certificates into the container.

$ip=(Get-NetIPAddress -AddressFamily IPv4 `
   | Where-Object -FilterScript { $_.InterfaceAlias -Eq "vEthernet (HNS Internal NIC)" } `
   ).IPAddress

docker run -d -p 8080:8080 -e DOCKER_HOST=${ip}:2376 -e DOCKER_TLS_VERIFY=1 -v "$env:USERPROFILE\.docker:C:\Users\ContainerAdministrator\.docker" --name=visualizer stefanscherer/visualizer-windows

Building a custom image

When building for Windows, see Running on Windows.

To build an up-to-date image for any architecture supported by node:8-alpine (currently amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le and s390x), execute the following command on a device of your target architecture:

$ docker build -t visualizer-custom:latest .

Afterwards you can start visualizer by using any of the commands stated above. Just replace dockersamples/visualizer with visualizer-custom. For example:

$ docker run -it -d -p 8080:8080 -v /var/run/docker.sock:/var/run/docker.sock visualizer-custom

TODO:

  • Take out or fix how dist works
  • Comment much more extensively
  • Create tests and make them work better
  • Make CSS more elastic. Currently optimized for 3 nodes on a big screen

More Repositories

1

example-voting-app

Example distributed app composed of multiple containers for Docker, Compose, Swarm, and Kubernetes
C#
4,558
star
2

atsea-sample-shop-app

A sample app that uses a Java Spring Boot backend connected to a database to display a fictitious art shop with a React front-end.
Java
688
star
3

101-tutorial

JavaScript
335
star
4

wordsmith

Sample project with Docker containers running under Kubernetes
Java
257
star
5

compose-dev-env

Example used to try a compose application with Docker Dev Environments
Go
137
star
6

docker-fifth-birthday

100
star
7

node-bulletin-board

Sample bulletin board app in Node.js and Vue.js
JavaScript
98
star
8

single-dev-env

Example used to try a single container sample of Docker Dev Environments
Go
86
star
9

dockercoins

HTML
71
star
10

global-2018-hol

Hands-On labs for the global 2018 event series
PHP
59
star
11

aspnet-monitoring

Monitoring ASP.NET Fx applications in Windows Docker containers, using Prometheus
JavaScript
56
star
12

linux_tweet_app

A very simple webapp based on NGINX
HTML
47
star
13

javaee-demo

Demo migrating a JavaEE application to Docker
Java
40
star
14

newsletter-signup

Newsletter Sign Up - a .NET Framework app using Docker containers on Windows
JavaScript
28
star
15

docker-hub-ml-project

Python
27
star
16

gopher-task-system

A Task System using Go Docker SDK.
Go
20
star
17

buildme

buildme
Dockerfile
18
star
18

windows-2003

Sample apps taken from Windows Server 2003 and running in Docker Windows containers
Dockerfile
14
star
19

link-shortener-typescript

A Simple URL Shortener built using TypeScript and Nest.js powered with Docker
TypeScript
14
star
20

wearedevelopers-2023

The sample application used for Docker's WeAreDevelopers 2023 talk
JavaScript
8
star
21

elastic-windows

Samples for Elasticsearch and Kibana running in Windows Docker containers
PowerShell
7
star
22

helloworld-demo-python

Demonstrating Hello World Python Example for docker init CLI
Python
7
star
23

student-record-management

Building a Student Record Management app using .NET and Docker
C#
7
star
24

docker-init-demos

Sample apps to demonstrate the power of docker init
Rust
6
star
25

.github

5
star
26

node-mongo-docker

Creating a REST API using Node, Mongo and Docker
JavaScript
3
star
27

dotnetconf19

Code for the 2019 .NET Conf challenge
C#
2
star
28

helloworld-demo-node

Example used to demonstrate docker init CLI for a simple Hello World Node Program
Dockerfile
2
star
29

build-cloud-cookbook

Rust
2
star
30

dind-rapid7

Shell
1
star
31

project-template

A Sample repository template for a new project
Dockerfile
1
star