chapter three

3 Publishing your first microservice

 

This chapter covers:

  • Learning the difference between Docker images and containers
  • Using Docker in your development environment
  • Packaging your microservice as a Docker image
  • Creating a private Docker registry
  • Publishing your microservice to your Docker registry
  • Instantiating your microservice in a Docker container

By the end of this book, we’ll have deployed multiple microservices to our production environment: our Kubernetes cluster. Before we can deploy an entire microservices application we must first be able to package and publish a single microservice. In this chapter we’ll take the video streaming microservice we created in chapter 2 and publish it so that it’s ready for deployment to our cluster.

In order to deploy a microservice to a cluster running in the cloud, we have to publish it somewhere accessible. To achieve this we must first package our code, assets and dependencies into a single bundle. We’ll then need a location in the cloud to host this package. For that, we’ll create a container registry. If you haven’t heard of containers yet, that will be explained soon.

In this book, we are emulating the building of a proprietary application for a private company. So security and privacy are important and that’s why we’ll be creating a private container registry as opposed to a public one. We’ll be creating this container registry manually on Azure, but later in chapter 6, we’ll learn how to create our registry from code.

3.1       New tools

3.2       Getting the code

3.3       What is a container?

3.4       What is an image?

3.5       Why Docker?

3.6       What are we doing with Docker?

3.7       Extending our development environment with Docker

3.7.1   Installing Docker

3.8       Packaging our microservice

3.8.1   Creating a Dockerfile

3.8.2   Packaging a Docker image

3.8.3   Booting our microservice in a container

3.9       Publishing our microservice

3.9.1   Creating a private container registry

3.9.2   Pushing our microservice to the registry

3.12  Summary