I wrote about the Yang Explorer in a docker quite some time ago, Yang Explorer was v0.6 at that time. Back then the motivation to create a docker image was pretty simple – installation was a pain in v0.6, it is still a pain, but the official version bumped to 0.8(beta).

So I decided to re-build an image, now using Alpine Linux as a base image to reduce the size.

Just take a look how noob-ish I was to publish a Dockerfile like this:

FROM ubuntu:14.04
MAINTAINER Roman Dodin <[email protected]>
RUN DEBIAN_FRONTEND=noninteractive apt-get update; apt-get install -y python2.7 python-pip python-virtualenv git graphviz libxml2-dev libxslt1-dev python-dev zlib1g-dev
RUN DEBIAN_FRONTEND=noninteractive git clone https://github.com/CiscoDevNet/yang-explorer.git
WORKDIR /yang-explorer
RUN bash setup.sh -y
RUN sed -i -e 's/HOST=\x27localhost\x27/HOST=$HOSTNAME/g' start.sh
CMD ["bash", "start.sh"]

Several unnecessary layers, using Ubuntu as a base – these are the Docker-novice errors.

Few things changed in the Yang Explorer regarding the setup process, now you do not need to install explicitly all the dependencies, they will be installed using the packaged requirements.txt file, so our Dockerfile could be as short as this:

FROM alpine

LABEL maintainer="[email protected], netdevops.me"

RUN apk add --no-cache bash git python && \
    python -m ensurepip && \
    rm -r /usr/lib/python*/ensurepip && \
    git clone https://github.com/CiscoDevNet/yang-explorer.git

WORKDIR /yang-explorer

RUN apk add --no-cache gcc py-crypto python-dev libffi-dev musl-dev openssl-dev libxml2-dev libxslt-dev && \
    bash setup.sh -y && \
    sed -i -e 's/HOST=\x27localhost\x27/HOST=$HOSTNAME/g' start.sh && \
    apk del musl-dev gcc

CMD ["bash", "start.sh"]

In the first RUN we write a layer with the tools that are needed to clone the official repo and in the second RUN we install build dependencies, go through setup process and uninstall unnecessary build dependencies to reduce the size.

Compressed image size is 358Mb. Uncompressed size is 1.9Gb

Layers disposition

Usage

To use this image:

  1. Start the container

    docker run -p 8088:8088 -d hellt/yangexplorer-docker
    
  2. Navigate your flash-capable browser to http://<ip_of_your_docker_host>:8088

Differences with Robert Csapo image

I outlined special aspects of Robert’ image in the original post. Main differences are in the size:

  • Compressed = 358Mb vs 588Mb
  • Uncompressed = 1.9Gb vs 2.51Gb

Links

Post comments are here.