Docker containers
Docker containers: how I started loving deployments.
I am like most programmers. Any time, deployments were mentioned, I had this looming dread take over.
So, when I read I could run everything local and then deploy exact same snapshot to prod, controlling all dependencies and variables, I was sold.
here is my journey as I learn more about docker
What is a docker container ?
Docker is a container management system which lets you create and manage Linux Containers (LXC) so that you can create images on your local machine which replicate production environment. This means, no surprises when going from test to prod.
here is how docker runs:
(Image src: Mastering docker book)
So this gives us the basic advantage where the containers do not need to load up OS every time and are much lighter and smaller compared to other VM systems.
Namespaces
Namespaces are the building blocks of a container. There are different types of namespaces and each one of them isolates applications from each other.PID namespace allows process inside the container to have its own process ID
With the pid namespace, we can run the same program multiple times in different isolated environments; for example, we can run different instances of Apache on different containers. But without the net namespace, we would not be able to listen on port 80 on each one of them. The net namespace allows us to have different network interfaces on each container. Loopback interfaces would be different in each container as well.
With the mnt namespace, a container can have its own set of mounted filesystems and root directories. Processes in one mnt namespace cannot see the mounted filesystems of another mnt namespace.
With the uts namespace, we can have different hostnames for each container.
Dockerfile
Dockerfile is a list of instructions to create the container. This includes base image, set of instructions to run or set environments and entry point into your application.Here is an example
FROM java:8VOLUME /tmp ADD artifactory.secureserver.net:10002/rg_core RUN bash -c 'touch /app.jar'ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
Lets go line by line to understand this file:
we are starting with JAVA 8 base container.


0 Comments:
Post a Comment
<< Home