In my last post, I discussed about varies security constructs available in Linux which help in creating a secure application environment. Other than these Linux kernel constructs, there are other best practices and architectures, which if followed can make container environment less vulnerable and thus more secure.
A sample Dockerfile below, explains on how to build Docker containers with statically linked and with syscall package
Unikernel
Small footprint - more secure
For next generation data center making use of public or in-house clouds, a statically linked small foot-print kernel aka. unikernel, has made possible to run lot many virtual appliance per host. Unikernel only include minimal functionality as needed by the application, thus making the host less vulnerable to attacks. An application not needing to take talk to outside world can avoid having a kernel stack consisting of networking components. This custom build kernel is statically linked to the application and shipping along with the application. MirageOS, a project at MIT is an example of such Unikernel. The team has proven with example deployments the level of security it offers when compared with a full size generic Linux distribution.
CoreOS
What is Linux? Tar ball of code called kernel? The kernel code can be downloaded from kernel repository, add with few utilities, create a tar ball and there you get a distribution. Various commercial distribution vendors - Redhat, Ubuntu, Suse are kind of doing the same. The vendors add value in making sure the distribution has all necessary utilities, make sure they work together and can provide support if anything breaks. CoreOS is one such distribution with an aim to make the distribution as small as possible. They get their tar balls, add only that stuff that would be needed to run "Docker Container" micro services. The distribution does not comewith any fancy gizmo, utilities, GUI, graphs but just enough to get things going with Docker.
The basic images boots up in less than a minute, and take just about 3GB of space. There is no package manager and one has to use Docker to pull any software. The default install does not let one login as any user, but wants to use cloud-init for any purpose of deployment. The cloud-init helps in bringing instances of CoreOS, as many, with application pulled from Docker registry.
In short, the concept of small size distribution not only works in favor of having a small footprint for the kernel but also makes the system less vulnerable. So, use CoreOS or anything similar.
Golang - nolibc
Golang, commonly referred a Go is a statically typed programming language. It is derived from C with capabilities such as garbage collection, dynamic arrays etc, and developed at Google. Always been a "C" programmer, I found learning Go super easy. Go comes with its own concurrency model, designed for better context switching between threads and not making each as a kernel thread. Engineers familiar with Unix threading model can easily understand and appreciate such differences. The language has implemented its own system call interface and does not use libc for calls into the kernel. All the code in Go is statically linked, though with 1.5 they started supporting shared libs. The basic idea of not using any system installed libraries for kernel talking brings the application written in Go to category of "less vulnerable".
![]() |
Go calls in system call without libc or anything else. |
A sample Dockerfile below, explains on how to build Docker containers with statically linked and with syscall package
FROM scratch
MAINTAINER Kelsey Hightower <kelsey.hightower@gmail.com> ADD contributors contributors
ENV PORT 80
EXPOSE 80
ENTRYPOINT ["/contributors"]
MAINTAINER Kelsey Hightower <kelsey.hightower@gmail.com> ADD contributors contributors
ENV PORT 80
EXPOSE 80
ENTRYPOINT ["/contributors"]
Conclusion
Micro-service architecture focusses on creating smaller components - functional, non-functionals of an application into a small separate entities. The life-cycle of these are managed independently, scaling up or down, and come with endpoint api's for communicating. Linux containers using Docker provides an easy way to compose such micro-services. The applications have to be small in size, secure and portable to run any environment. Small footprint of the application, with less dependency on the host based libraries or entities are the key to a successful secure micro service architecture.
In my next post, few more solution from Docker and some tricks using which container data management can be made easy & secure.
In my next post, few more solution from Docker and some tricks using which container data management can be made easy & secure.