{"id":9025,"date":"2020-01-20T07:42:18","date_gmt":"2020-01-20T07:42:18","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=9025"},"modified":"2021-11-13T07:06:29","modified_gmt":"2021-11-13T07:06:29","slug":"docker-interview-questions-and-answer-part-16","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/docker-interview-questions-and-answer-part-16\/","title":{"rendered":"Docker Interview Questions and Answer Part \u2013 16"},"content":{"rendered":"\n<p><strong>Which of the following will upload a new stack to your Docker Cloud account?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>docker-cloud stack create docker-cloud.yml<\/li><li><strong>docker-cloud stack create -f docker-cloud.yml (Ans)<\/strong><\/li><li>docker-cloud stack create -f dockerfile<\/li><li>docker stack create -f docker-cloud.yml<\/li><\/ul>\n\n\n\n<p><strong>Docker Engine is:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>The locally installed runtime through which you administrate Docker containers (Ans)<\/strong><\/li><li>An online Docker administration interface<\/li><li>An online Docker image repository<\/li><li>A local Docker image repository<\/li><\/ul>\n\n\n\n<p><strong>Docker Trusted Registry is:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>A local, commercial image management tool<\/li><li>An open source tool for securing the infrastructure on which Docker Engine runs<\/li><li><strong>A web-based, commercial, hosted image management tool (Ans)<\/strong><\/li><li>An open source tool for coordinating Docker container clusters<\/li><\/ul>\n\n\n\n<p><strong>A Docker container will run faster when its image is properly optimized. Which of the following will have the greatest positive impact on speed?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Build the image using as few layers as possible. (Ans)<\/strong><\/li><li>Always base your images on the latest operating system version available.<\/li><li>Always be consistent in the software package versions you choose for your image layers.<\/li><li>Build the image using a Dockerfile rather than from a running container.<\/li><\/ul>\n\n\n\n<p><strong>Where are the image files stored on a Linux machine running a package-based Docker Registry?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\/var\/lib\/docker\/docker-registry<\/li><li>\/var\/lib\/docker\/volumes\/\/_data\/docker\/registry\/v2\/repositories\/<\/li><li><strong>\/var\/lib\/docker\/docker-registry\/docker\/registry\/v2\/repositories (Ans)<\/strong><\/li><li>\/var\/lib\/docker\/docker-registry\/docker\/registry\/v2\/_catalog<\/li><\/ul>\n\n\n\n<p><strong>Which of these commands will return a list of images currently stored in a Docker Registry?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>docker images<\/li><li><strong>curl 192.168.1.17:5000\/v2\/_catalog (Ans)<\/strong><\/li><li>curl 192.168.1.17:5000\/v2\/_data<\/li><li>docker registry ls<\/li><\/ul>\n\n\n\n<p><strong>Which of the following commands will successfully build an image with the name &#8220;myimage&#8221;?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>docker build -t myimage<\/li><li>docker build &#8211;tag-image myimage<\/li><li>docker build -n myimage .<\/li><li><strong>docker build -t myimage . (Ans)<\/strong><\/li><\/ul>\n\n\n\n<p><strong>What does &#8220;retries&#8221; specify for a health check?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>How many times a container is restarted before it&#8217;s marked unhealthy<\/li><li>How many times an individual health check is simultaneously performed before assuming a failure<\/li><li>How many times a container is restarted before its task is shutdown and a new one is created<\/li><li><strong>How many times a health check fails before a container is marked unhealthy (Ans)<\/strong><\/li><\/ul>\n\n\n\n<p><strong>docker-compose is roughly equivalent to what swarm mode command: __?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>docker stack deploy (Ans)<\/strong><\/li><li>docker service create<\/li><li>docker run<\/li><\/ul>\n\n\n\n<p><strong>What purpose does the ingress network serve?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Routing traffic from published ports to running containers (Ans)<\/strong><\/li><li>Load balancing internal container to container traffic<\/li><li>Routing internal container to container traffic<\/li><\/ul>\n\n\n\n<p><strong>How are secrets made available to a container?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Environment Variables<\/li><li><strong>Filesystem (Ans)<\/strong><\/li><li>Socket<\/li><li>HTTP API<\/li><\/ul>\n\n\n\n<p><strong>Pinning is the process of ______?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Resolving an image tag to a digest (Ans)<\/strong><\/li><li>Assigning a image repository to a digest<\/li><li>Assigning a task to a node<\/li><li>Assigning a container to a task<\/li><li>Resolving a image digest to a tag<\/li><\/ul>\n\n\n\n<p><strong>Which published port mode would you use to map the port on a given node to a specific container running on that node?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Host     (Ans)<\/strong><\/li><li>LoadBalanced<\/li><li>Ingress<\/li><li>None<\/li><li>Bridge<\/li><\/ul>\n\n\n\n<p><strong>Services are a template for:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Containers<\/li><li><strong>Tasks (Ans)<\/strong><\/li><li>Images<\/li><li>Swarms<\/li><\/ul>\n\n\n\n<p><strong>If you only have a global service, what will happen when you add a new node to the cluster?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>The pending task for the service will be assigned to the new node and a container will be started.<\/li><li><strong>A new task will be allocated to the new node for the global service. (Ans)<\/strong><\/li><li>The existing containers for the service will be rebalanced so that a fair share are placed onto the new node.<\/li><li>Nothing will run on the new node unless you change the service.<\/li><\/ul>\n\n\n\n<p><strong>Let&#8217;s say you have a service with four replicas, and four tasks currently running with IDs: A, B, C, and D. Let&#8217;s say you stop the container associated with task D. <br>    What happens?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>The service is terminated.<\/li><li><strong>A new task E and a new container are created. Task D and its container are removed. (Ans)<\/strong><\/li><li>The container is restarted.<\/li><li>The container is removed, and a new one is created and associated with Task D.<\/li><\/ul>\n\n\n\n<p><strong>What happens if you try to view cluster state from a worker only node?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>List of cluster state for all nodes<\/li><li>List of state for that worker node only<\/li><li><strong>An error (Ans)<\/strong><\/li><\/ul>\n\n\n\n<p><strong>How can you see a log of health checks?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>docker service ps MYSERVICE<\/li><li>docker ps<\/li><li><strong>docker inspect CID (Ans)<\/strong><\/li><li>docker service inspect MYSERVICE<\/li><li>docker stack ps MYSTACK<\/li><\/ul>\n\n\n\n<p><strong>If you want to convert a worker node into a manager node, what do you use?<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>docker node demote<\/li><li>docker swarm worker<\/li><li>docker swarm manager<\/li><li><strong>docker node promote (Ans)<\/strong><\/li><li>docker node rm<\/li><\/ul>\n\n\n\n<p><strong>A stack manages multiple:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Replicas<\/li><li>Nodes<\/li><li>Containers<\/li><li>Tasks<\/li><li><strong>Services (Ans)<\/strong><\/li><\/ul>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_70745\"><iframe loading=\"lazy\"  id=\"_ytid_79115\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_70745\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Which of the following will upload a new stack to your Docker Cloud account? docker-cloud stack create docker-cloud.yml docker-cloud stack create -f docker-cloud.yml (Ans) docker-cloud stack create -f dockerfile docker&#8230; <\/p>\n","protected":false},"author":1,"featured_media":10438,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[4862],"tags":[567],"class_list":["post-9025","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-docker","tag-docker"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/9025","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=9025"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/9025\/revisions"}],"predecessor-version":[{"id":25053,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/9025\/revisions\/25053"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/10438"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=9025"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=9025"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=9025"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}