You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
8.1 KiB

import { addBanner, addArticle, addTitle, addHeader, addParagraph, addSubHeader } from '/scripts/article.js';
import { addInset, addInsetList, addInsetCodeListing, addInsetBulletList } from '/scripts/inset.js';
import { addImageWithCaption, addButtonGroup } from '/scripts/visuals.js';
import { addSidebar} from '/scripts/sidebar.js';
import { addSyntax } from '/scripts/code.js';
const heading = document.querySelector(".heading");
const global = document.querySelector(".global_menu");
const local = document.querySelector(".local_menu");
const sidebar = document.querySelector(".sidebar");
const main = document.querySelector(".main_content");
heading.append(addTitle("Docker For Windows"));
heading.append(addParagraph("David Davis - LinkedIn Learning - November 2018"));
heading.append(addParagraph("Chapter 1 - UNDERSTANDING CONTAINERS"));;
main.append(addHeader("WHAT IS A CONTAINER?"))
main.append(addParagraph("A container is really just somewhere you can install an application like a web server. It will use the hosts operating system but it doesn't have to be for instance, a Windows app if you are running it on Windows. You can run a Linux app in a container but you do need to have WSL installed for that."))
main.append(addParagraph("Containers have number of advantages. They are"))
main.append(addSyntax("Lightweight"))
main.append(addParagraph("They are a little bit like VMs and you could see them as a replacement for VMs but they don't need their own OS."))
main.append(addSyntax("Interchangeable"))
main.append(addParagraph("Pets vs Cattle analogy. Containers are not treated as pets, you don't really care too much about them. They are treated more like cattle, kept while they are useful and then disposed of or replaced. You might not even know their names!"))
main.append(addSyntax("Portable"))
main.append(addParagraph("It's easy to transfer a container between different machines and platforms. You could, for example, store a container in the cloud so that it can be downloaded to whatever machine you want to deploy it on."))
main.append(addSyntax("Scalable"))
main.append(addParagraph("If demand changes, it is easy to add or remove containers."))
main.append(addSyntax("Stackable"))
main.append(addParagraph("You can create a stack of containers that will give you a hierardy of inter-related services and you can orchestrate these as a kind of cohesive unit. You can also scale at the level of stacks of containers."))
main.append(addSyntax("Secure"))
main.append(addParagraph("A container is separate from the rest of the host machine."))
main.append(addSyntax("Complete"))
main.append(addParagraph("A container will contain everything you need to run an app so in that sense, downloading a container is more like downloading an app than it is like setting up a VM. Once downloaded, it is ready to run, you don't have to install it. You might think of this as being similar to downloading an image that you can run in, for example, Virtual Box. A container does have elements of both."))
main.append(addParagraph("You could sum this up by saying that a contained is just a simple and quick way to run an application."))
main.append(addHeader("CONTAINERS VS VIRTUAL MACHINES"))
main.append(addParagraph("The main difference between a container and a virtual machine is the operating system. They both need one but docker uses the operating system already installed on the host machine, but a virtual machine has to have it's own operating system installed and licensed. This is illustrated in figure 1."))
main.append(addImageWithCaption("./images/figure1.jpg", "Figure 1 - the difference between containers and virtual machines. "))
main.append(addParagraph("When comparing the two, the disadvantages of using a VM are fairly obvious. Since you need to install an OS for it, this means the VM will generally be larger and more resource hungry. You also have the overheads associated with as OS which might include purchasing a licence as well as securing it and keeping it up to date."))
main.append(addParagraph("In addition, it will normally take longer to boot up a VM than it would be to start a container."))
main.append(addParagraph("For containers, it isn't as easy to run traditional applications and these may have to be modified to run in a container. Although a container does keep an application isolated from the rest of the system, you don't get the same level of isolation that you would with a VM, particularly since the container doesn't have it's own operating system."))
main.append(addParagraph("With VMs, you may be able to take advantage of some features such as high availability, resource scheduling and so on which may not be available with containers yet."))
main.append(addParagraph("Virtual machines represent a more mature rechnology compared to containers and you may find that reflected in the resources available to you. That might include books, web based tutorials, blogs or courses like those on LinkedIn Learning. On that last point, there are lots of courses on LinkedIn Learning Hat are either about Docker or cover it to some degree if it is relevant to the course subject. You will probably find, especially with older courses, that where vitrualization is relevant to the course, the course is more likely to feature VMS than containers."))
main.append(addParagraph("Lastly, and to some degree this is a personal thing, I already have some experience with VMS so I can use one without having to learn about them first. This is not the case with containers. At this point, I don't really know anything about using containers so I would have to say a VM would be easier to use since there is no real learning curve. I am inclined to think that they are easier to use in general so it will be interesting to revisit this when I have completed the course to see if I have changed my mind!"))
main.append(addHeader("DOCKER IMAGES AND CONTAINERS"))
main.append(addParagraph("In Docker, am image is simply a fully-packaged and ready-to-run application. We saw that with an earlier example where we downloaded an nginx image and started the container which immediately allowed us to view the nginx default site. We didn't have to install it."))
main.append(addParagraph("The image for an application, such as nginx, also includes the dependencies including libraries, runtime files, config files and so on."))
main.append(addParagraph("It seems reasonable at this post to think than an image is another name for a container. To give you some idea of the difference, run the following commands."))
main.append(addSyntax("docker ps"))
main.append(addParagraph("and then"))
main.append(addSyntax("docker images"))
main.append(addParagraph("The ps command lists containers and the images command lists images . At the moment, I have downloaded several images and I have one running. The output I get from running these commands is shown in figure 2."))
main.append(addImageWithCaption("./images/figure2.jpg", "Figure 2 - the output from the docker ps and images commands."))
main.append(addParagraph("As you can see, nextcloud is listed as an image and a container but there are another 6 images you don't see listed under containers. This is because they are not currently running."))
main.append(addParagraph("A container is simply an image that has been started up and is running. I suspect that you will often find these terms being used interchangeably but the distinction can be important if you are running a command specific to one or the other. The ps command is a good example of that. If you run the command expecting to see a list of all the images you have downloaded, you might be surprised. You won't see any that are not running."))
main.append(addParagraph("You should think of the ps command as being the command you would use to check if a particular application is currently running and the images command to see what applications have already been downloaded. For instance, let's say we want to check on the status of nextcloud. We can run the images command to confirm that it has been downloaded and is available to run. If you follow that up with the ps command, it will show you whether it is currently running."))
addSidebar("programming");