Home > Undergraduate > Open Source Tools and Scripting > Labs |
CITS2003 OPEN SOURCE TOOLS AND SCRIPTING | |
|
|
Lab 1: DockerDocker is a system for running virtual computers inside your real computer. We are using Docker so that all students can run the same Ubuntu Linux lab environment, regardless of what computer they own. The virtual computers that Docker runs are called containers. A container is based on a read-only template called an image, which contains the operating system, files etc. that are present when the container starts. We will be using an image based on Ubuntu for the CITS2003 labs. We will be installing Docker using Docker Desktop. This is an easy-to-install package that includes a Docker daemon and client (both GUI and command line client). The Docker daemon runs in the background, and we will use the command line Docker client to perform Docker commands such as launching containers. The GUI client is not much use to us. For more information on what Docker is, see Lecture 2: Docker. InstallationThese instructions are based on the CITS1003 Docker Setup Instructions written by David Glance.
Follow the steps for your Operating System. WindowsWindows Subsystem for Linux (WSL) is a prerequisite for running Docker on Windows. If you have not already installed WSL, install it now. Please follow the official Microsoft instructions. It is likely that Ubuntu 22.04 will be default version. If not, use the Microsoft installation instructions to choose that version. If version 22.04 is not yet supported, 20.04 is also fine, for our purposes. TroubleshootingThere are several things that can go wrong with your WSL install: Mac (Intel x86)You can check what chipset your machine uses by clicking on "About this Mac" in the Apple menu (top left of the screen). If your Mac is more than a couple years old you probably have an Intel x86 Mac. There are no additional steps for this system. M1 Mac (ARM)If you have a new Mac (purchased in the last year or two), you may have an M1 mac. M1 Mac uses a different chip-set to Intel Macs, so it cannot directly run code based on the Intel x86 chip-set. However, it can run programs built for Intel using an emulator called Rosetta 2. If you have not already installed Rosetta 2, install it now: Download the correct installer from https://www.docker.com/get-started. Follow the steps in the installer to install Docker Desktop. If you want to read the official installation instructions, you can find them here. Run DockerStart Docker DesktopCongratulations, you have installed Docker! Run Docker Desktop (if you haven't already) to start the Docker Service. Once Docker Desktop opens, you should see a little whale icon on your taskbar showing that the Docker daemon is running. If this ever goes away, you can restart it by opening Docker Desktop again. Go ahead and close Docker Desktop: the daemon will keep running in the background. Warning: don't use Docker Desktop to launch your docker images. It gives you a weird prompt and won't automatically stop the image when you log out. This is a recipe for confusion, so stick to the command line! Help, my Docker on Windows had a "failed to initialise" error!: you probably failed to install WSL properly, go back to the windows WSL troubleshooting steps Open a terminalWe will use the command line to launch Docker. The command line can be accessed using the terminal application on your OS.WindowsOpen Command Prompt or Windows Powershell. You can find both of these by searching in the Start menu. Do not run as administrator, you can open it normally.
MacOpen the terminal app.Download the Docker imageOnce the Docker daemon is running, we can use the Docker client to perform Docker commands. Start by downloading the Docker image for the labs:
Create a directory on your host machineIt's time to create a directory (folder) to store your lab work. We also need the absolute path of this directory so that we can mount it into a container. The steps to do this vary slightly depending on your OS: WindowsCreate a directory:mkdir ostsMove into the directory you created: cd ostsPrint the absolute path to the current location (command prompt): cdOR print the absolute path to the current location (Powershell): pwd Depending on where you created the directory, your path should look something like this: MacCreate a directory:mkdir ostsMove into the directory you created: cd ostsPrint the absolute path to the current location: pwd Depending on where you created the directory, your path should look something like this: Launch the containerOnce you have the absolute path for your docker run -it --mount type=bind,source="/Users/dan/osts",target=/home/stud/perm mjw263/osts_2023:v1 After you run this command, you will notice that your command prompt changes to something like To exit the container, use the
|
Department of Computer Science & Software Engineering The University of Western Australia Created By: Daniel Smith 8 February 2022 Last modified: 1 February 2023 Modified By: Michael Wise |
|