Question-41: What is CRI (Container Runtime Interface)?

Answer: You want interface to the container using API and that is defined by the Container Runtime Interface standard. And this CRI API can be implemented by a number of different programs for example

  • By Docker: containerd-cri
  • By RedHat: cri-o

Question-42: In Kubernetes how each container would be launched?

Answer: In Kubernetes usually containers are launched by a daemon on each node called the Kubelet.  However, you can use Docker Command Line utility as well to deploy the containers. For example below command

      docker run -d --name HE –publish 8080:8080 registryURL/HEImage

In above command, it starts an HEImage container which maps the ports 8080 of your local machine to 8080 in container. Here, -d option specifics that run this in background as daemon process. Here, --name is giving a name to your container (e.g. HE)  which you are getting from registry.

Question-43: What port forwarding is required where container is started?

Answer:  When you start a container a port forwarding is required because each container gets its own IP, so listening on localhost inside the container does not cause you to listen on your machine. And without port forwarding, connections will not be accessible to your machine.

Question-44: How you can limit the resources use by Docker container application?

Answer: You can limit the resources used by a Docker Container application by exposing the underlying cgroup technology provided by the Linux Kernel. And same is used by the Kubernetes to limit the resources used by each pod.

Question-45: How can you specify that container application is limited to 512MB memory and 2GB as swap space?

Answer: For that you can use --memory and --memory-swap flags when you are using “docker run” command as below

docker run -d --name HE \

--publish 8080:8080 \

--memory 512m \

--memory-swap 2G \

registryURL\HEImage

If your program is trying to use much more memory then it can be terminated. Similarly the way JVM crashes on native OS, when it tries to occupy more memory than allocated.