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.

55 lines
6.0 KiB

3 months ago
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';
import { menu } from '/scripts/web_dev_buttons.js';
import { global_menu } from '/scripts/grid_layout1.js';
import { local_menu } from '/scripts/programming.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(addParagraph("Carlos Nunez - LinkedIn Learning - December 2022"));
heading.append(addParagraph("INSTALLING AND SETTING UP DOCKER"));
global.append(global_menu());
local.append(local_menu("learningdocker"));
main.append(addHeader("Installing and Setting Up Docker"));
main.append(addParagraph("What does Docker do?"));
main.append(addSyntax("It manages a Linux servers and starts/stops containers as required."));
main.append(addSyntax("It provides tools to make management almost transaprent."));
main.append(addSyntax("It runs on Linux but this can be in a VM including WSL."));
main.append(addSubHeader("Sidebar: Installing Docker on a Raspberry Pi"));
main.append(addParagraph("I originally wanted to install Docker in order to set up my own search engine so I started by installing it on my Pi. As you will see later, I installed it again on a cloud server. As it happens, installing it on a Raspberry Pi is quite easy so I will just mention the process here."));
main.append(addParagraph("In doing that, I was following a set of instructions from an main on pimylifeup.com called <a href='https://pimylifeup.com/raspberry-pi-docker/'>Installing Docker on the Raspberry Pi</a> ny Emmet."));
main.append(addParagraph("As always, it is a good idea to make sure your system is up to date."));
main.append(addSyntax("sudo apt update && sudo apt upgrade -y"));
main.append(addParagraph("We can then install Docker with the command"));
main.append(addSyntax("curl -sSL https://getdocker.com | sh"));
main.append(addParagraph("SECURITY NOTE: In the above command, we are piping the output of the curl command to a shell and this is not recommended. In this case, getdocker.com is a trusted source and this is why the command is given in this way in the main. I did install Docker with this command but it is important to recognise that this is not a good practice."));
main.append(addParagraph("Once Docker has been installed, it will generally create a group called docker and membership of the group will allow users to use docker without sudo. This was the case here so I haven't included the command to create a group. The command"));
main.append(addSyntax("groups"));
main.append(addParagraph("in order to confirm that the group has been created."));
main.append(addParagraph("We can add a user to the docker group with the command"));
main.append(addSyntax("sudo usermod -aG docker $USER"));
main.append(addParagraph("You can add any username in place of $USER. If you run the command as shown with $USER, it will add the current user."));
main.append(addParagraph("In order for the change in groups to take effect, you need to log in after the command had been executed to add that user. THe easiest way to do that is to log out and then log back in again or you can use the switch user command - su - to produce the same effect."));
main.append(addParagraph("We can test the installation to ensure that docker has been installed and is working by starting up a container."));
main.append(addSyntax("docker run hello-world"));
main.append(addParagraph("The output this produces may start with a message to the effect that the image cannot be located and that's fine, it just means that it has to be installed and this would happen automatically if needed. The output it produces is shown in figure 1."));
main.append(addImageWithCaption("images/helloworld.png", "Figure 1 - the output from running the command to start up the hello-world container."));
main.append(addParagraph("Docker is two things, the client and the server. When you run it from a command line, you are interacting with the docker client. The client connects to the docker server and runs a virtual machine. Docker is largely automated so a lot of the time you will just be starting and stopping it. As a side note, when we ran the command producing the output in figure 1."));
main.append(addHeader("Installing Docker on Windows"));
main.append(addParagraph("I am not intending to use Docker on Windows but I am installing it anyway because I may need it for some parts of the course. It's easy enough to install and can be downloaded from <a href='https://pimylifeup.com/raspberry-pi-docker/'>docker.com</a>."));
main.append(addParagraph("I don't think that you need to register for a docker account but I did that anyway and you can also do that on docker.com."));
main.append(addParagraph("Once it has been installed, you can run docker from a command prompt in the same way that we ran it from a Linux machine. This time, we will start it up with the getting-started container so the command is"));
main.append(addSyntax("docker run -d =p 80:80 docker/getting-started"));
main.append(addParagraph("Again, the image will be downloaded if necessary and the output from running this command is shown in figure 2."));
main.append(addImageWithCaption("images/gettingstarted.png", "Figure 2 - the output from running the command to start up the getting-started container in Windows."));
main.append(addParagraph("One advantage of running docker in Windows is that you have the Whale icon in the system tray when docker is running and you can use "));
main.append(addButtonGroup([">>", "./using.html","Learning Docker", "./installing.html", "Raspberry Pi", "/raspberrypi/raspberrypi.html", "Home", "/index.html"]));
addSidebar("programming");