Configure CI/CD for dockerized apps using VSTS and deploy to ACS

n this blog post, we’ll discuss how to configure CI/CD for dockerized apps using Visual Studio Team Services (VSTS) and deploy to a Linux based kubernetes cluster in Azure Container Services (ACS). For building dockerized app, we’ll use .NET core and build a linux based docker image. Also we’ll be using Azure Container Services to deploy Linux based Kubernetes cluster and Azure Container Registry for providing docker registry.

Deploy Kubernetes cluster on ACS

For this, please refer to this blog post here.

Deploy Azure Container Registry

Continue reading “Configure CI/CD for dockerized apps using VSTS and deploy to ACS”

Docker Cheat Sheet

I have spent some time to gather list of most used docker commands and below is a summary for same. These are not full blown commands, just to get you started and then you can use inbuilt command help.

Lifecycle

  • docker create Creates a container
  • docker rename Renames a container
  • docker run Creates and runs a container
  • docker rm Removes a container
  • docker update Updates a container resource limits

Continue reading “Docker Cheat Sheet”

Running PowerShell Core in a docker container

PowerShell core is the edition of PowerShell built on top of .NET Core. It is sometimes simplified to “CoreCLR”, though it technically includes CoreFX as well.

PowerShell Core is cross-platform, available on Windows, macOS, and Linux, thanks to the cross-platform nature of .NET Core. On PowerShell Core, $PSVersionTable.PSEdition is set to Core.

Do note that  while PowerShell Core 6.0 is cross-platform, there is also a PowerShell Core 5.0/5.1 released exclusively as part of Nano Server. In this blog post, we’ll learn how to run PowerShell core in a docker container. Continue reading “Running PowerShell Core in a docker container”

Remove images from Docker Images

You can remove an image using its short or long ID, its tag, or its digest in the Docker. For this we have to use the command:

docker rmi [OPTIONS] IMAGE [IMAGE...]

Where Options are:
-f, –force Force removal of the image
–help Print usage
–no-prune Do not delete untagged parents

Let’s see how this works. You cannot delete an image if it has been used to spawn containers or child images based on it. You would likely see an error message which resembles following:

Error response from daemon: conflict: unable to remove repository reference “mogo/ubuntu:telnet” (must force) – container 4888c45aa31c is using its referenced image a955c52ec9ec

Or Continue reading “Remove images from Docker Images”

Change directory to store containers and images in Docker

As discussed in one of the previous posts, docker is more focused on ease of use and not so much on the disk space efficiency out of the box. However, it is our responsibility to maintain adequate free space on hard disk and also do some kind of standardization. DevOps is not only about automation but it is also about standardization of process thereby removing any gotchas or discrepancy in the configuration. For example, we may like to store docker images in a separate directory that may be located on a mounted device storage or some other easy to navigate configuration.

By default, docker store containers and images in /var/lib/docker by default:

Default directory for containers and images in Docker
Default directory for containers and images in Docker

Continue reading “Change directory to store containers and images in Docker”

Clear Docker Cache to save disk space

It is very easy to spin up a new container in Docker based on an image. However, when you exit the container, this container is not deleted. Docker always keeps a copy of it. This enables you to restart your container any time later.

When you first create a container in docker, its associated dockerfile is called and executed to create that container. This creates a new Docker image, which is stored in the folder ‘/var/lib/docker’ by default. During further runs of Dockerfile, Docker will create and commit a new layer to the already existing image. These images are stored in the cache.

Over the period of time, disk space occupied by these images can become significant. So you need to keep a tab on the disk usage.If you are no longer using exited containers, you can use below command to save up disk space:

$ docker rm $(docker ps -q -f status=exited)

Continue reading “Clear Docker Cache to save disk space”

Configure docker to start on boot on Linux

Most current Linux distributions (RHEL, CentOS, Fedora, Ubuntu 16.04 and higher) use systemd to manage which services start when the system boots. We can use below commands to configure docker to start on boot:

$ sudo systemctl enable docker

To disable this behavior, use disable instead.

$ sudo systemctl disable docker

If you are running on Ubuntu 14.04 LTS or lower, you can use upstart to help you with same:

$ echo manual | sudo tee /etc/init/docker.override