{"id":23595,"date":"2021-09-15T04:48:34","date_gmt":"2021-09-15T04:48:34","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=23595"},"modified":"2025-07-12T05:41:42","modified_gmt":"2025-07-12T05:41:42","slug":"docker-lab-excercise-assignment-1","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/docker-lab-excercise-assignment-1\/","title":{"rendered":"Docker Lab, Excercise &#038; Assignment &#8211; 1"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Requirements<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Linux<\/li>\n\n\n\n<li>OS X<\/li>\n\n\n\n<li>Windows 7.1, 8 or newer BUT NOT Windows 10.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Install<\/h3>\n\n\n\n<p><a href=\"https:\/\/www.devopsschool.com\/blog\/how-to-install-docker-in-linux\/\">Docker Installation and Configuration<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Pull commonly used images<\/h3>\n\n\n\n<p>The following images will be used during the workshop and may be pulled in advance to limit network usage.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>debian &#8211; Official Debian Image<\/li>\n\n\n\n<li>ubuntu &#8211; Official Ubuntu Image<\/li>\n\n\n\n<li>scratch &#8211; Base image for other images, 0 bytes, no need to pull this<\/li>\n\n\n\n<li>busybox &#8211; Minimal Linux distro, 2.5MB<\/li>\n\n\n\n<li>node &#8211; Official Node.js image<\/li>\n\n\n\n<li>redis &#8211; Official Redis image<\/li>\n\n\n\n<li>mongo &#8211; Official Mongo image<\/li>\n\n\n\n<li>postgres &#8211; Official Postgres image<\/li>\n\n\n\n<li>jwilder\/nginx-proxy &#8211; Nginx image with automatic proxy configuration of other containers.<\/li>\n\n\n\n<li>andersjanmyr\/counter &#8211; Counter web-service with support for multiple databases.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Running Containers<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">Use a simple throwaway container<\/h4>\n\n\n\n<p>In this section you will learn how to start and stop containers.<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">$ docker run -it --rm busybox \/bin\/sh  <\/code><\/span><\/pre>\n\n\n<ul class=\"wp-block-list\">\n<li>docker run\u00a0&#8211; Start a docker container.<\/li>\n\n\n\n<li>-it\u00a0&#8211; Interactive, pass stdin (-i) as a tty, pass signals (-t).<\/li>\n\n\n\n<li>&#8211;rm\u00a0&#8211; Remove the container once it is stopped.<\/li>\n\n\n\n<li>busybox\u00a0&#8211; A minimal docker image<\/li>\n\n\n\n<li>\/bin\/sh\u00a0&#8211; The command to run, start a shell.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Use a simple &#8220;persistent&#8221; container<\/h3>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">$ docker run -it busybox \/bin\/sh  <\/code><\/span><\/pre>\n\n\n<p>Same as before, but no &#8211;rm to remove the container once you exit.<\/p>\n\n\n\n<p><strong>Run some commands, create a couple of files, then exit exit-command or Ctrl-D<\/strong><\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># List all containers, including stopped  <\/span>\n$ docker ps --all    \n\t\t\t\n<span class=\"hljs-comment\"># List all running containers  <\/span>\n$ docker ps    \n\t\t\t\n<span class=\"hljs-comment\"># List all container IDs (-q quiet)  <\/span>\n$ docker ps --all -q    \n\t\t\t\n<span class=\"hljs-comment\"># List latest (-l) container, including stopped  <\/span>\n$ docker ps -l    \n\t\t\t\n<span class=\"hljs-comment\"># List ID of latest container  $ docker ps -l -q    <\/span>\n\t\t\t\n<span class=\"hljs-comment\"># Stop the last container  <\/span>\n$ docker stop $(docker ps -l -q)    \n\t\t\t\n<span class=\"hljs-comment\"># Start and attach to the stopped container <\/span>\n$ docker start -ia $(docker ps -l -q)    \n\t\t\t\n<span class=\"hljs-comment\"># Exit the container, exit or Ctrl-D    <\/span>\n\t\t\t\n<span class=\"hljs-comment\"># List the container and remember its name.  <\/span>\n$ docker ps -a    \n\t\t\t\n<span class=\"hljs-comment\"># List the logs of the container by name  <\/span>\n$ docker logs name-of-container   \n\t\t\t\n<span class=\"hljs-comment\"># Remove the container  <\/span>\n$ docker rm $(docker ps -l -q) <span class=\"hljs-comment\"># Or use the name<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_86770\"><iframe loading=\"lazy\"  id=\"_ytid_88078\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&autoplay=0&cc_load_policy=0&cc_lang_pref=&iv_load_policy=1&loop=0&rel=1&fs=1&playsinline=0&autohide=2&theme=dark&color=red&controls=1&disablekb=0&\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_86770\"  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>\n","protected":false},"excerpt":{"rendered":"<p>Requirements Install Docker Installation and Configuration Pull commonly used images The following images will be used during the workshop and may be pulled in advance to limit network usage. Running&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[4862],"tags":[],"class_list":["post-23595","post","type-post","status-publish","format-standard","hentry","category-docker"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/23595","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=23595"}],"version-history":[{"count":5,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/23595\/revisions"}],"predecessor-version":[{"id":49979,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/23595\/revisions\/49979"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=23595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=23595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=23595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}