COMP1511 17s1 Docker for COMP1511 Introduction to Programming
Docker allows you to run Linux programs on your own computer without installing Linux. We've created a Docker image containing the Linux programs which COMP1511 work needs. Installing Docker and downloading this image is one way you can set up your own computer to work on COMP1511. This is the first time we've used Docker for first year so please be patient if the information you are given isn't perfect.

Not all computers can run Docker - don't panic if your computer can't run Docker. There are other ways to work on COMP1511 on your own computer - almost any computer can be used to work at home.

Docker requires a 64-bit operating system (you can't run it on 32-bit versions of Windows). You also need 4+ Gb of memory (RAM) to run Docker.

You will need to download a Docker image of 150 megabytes - be careful if you have a limited internet quota. Do not download this via your phone! If you don't have a large internet quota at home you may be able to download Docker images via Uniwide while you are at UNSW.

Installing Docker for Windows (Windows Education/Pro/Enterprise)

The best way to use Docker on Windows is via the native Windows Docker application. How this does not work with all versions of Windows. It will work with 64-bit Windows 10 Pro or Enterprise if you happen to be running these versions of Windows. It will not work with Windows Home and support was disabled last year in the "Anniversary Update" to Windows 10 Education ( available free to COMP1511 students )

Follow the instructions for installing Docker (stable or beta should be fine). Note Docker will enable Hyper-V which may cause problems if you run VirtualBox.

After Docker is installed you need to enable access to your local drive via Docker settings enable access to your local drive via Docker settings (click on the Docker Icon in the System Tray)

If your machine has less than 8Gb of memory you probably want to reduce the amount of memory used by Docker to the minimum (1 Gb) in Docker Settings as well.

Then open a Command Prompt or PowerShell

Then enter the Docker commands below.

Installing Docker on OS X 10.10.3 Yosemite or newer

Follow the OS X installation instructions.

Hints to be added here (contributions welcome)

Installing Docker Toolbox

Docker can be installed on older OSX versions and 64-bit Windows versions without Hyper-V (e.g.Windows Home) via Docker Toolbox

Starting Docker and mounting volume is different (and a little more complicated) using Docker toolbox.

After installing Docker Toolbox, click on the shortcut for Docker Quickstart terminal to run it:

                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
           \______ o           __/
             \    \         __/
              \____\_______/
docker is configured to use the default machine with IP 192.168.99.100
For help getting started, check out the docs at https://docs.docker.com
Start interactive shell
andrewt@DESKTOP-D5CH4U3 MINGW64 ~

then enter the Docker commands below.

Hints to be added here (contributions welcome)

Installation on Linux

Follow the the instructions for your distribution.

Hints to be added here (contributions welcome)

Checking Docker Is Working

See if you can run a simple Docker image:
C:\users\andrewt>docker run hello-world

Hello from Docker!
...
You will need to mount your directory into Docker to do any work, so test if this works.

The command line option -v /c/Users/andrewt:/root causes the local directory /c/Users/andrewt to be mounted in the container as /root. You'll need to change the andrewt part of course.

C:\users\andrewt>docker run -v /c/Users/andrewt:/root alpine ls /root
AppData
Application Data
Contacts
Cookies
Desktop
Documents
Downloads
...
If you don't see any files make check you have the right directory name.

Using Docker for COMP1511

Now use Docker to start a Bash shell:

Beware this will involve a 150Mb download the first time you run it, and take several minutes.

Don't forget the -it command line argument - you need that to use Docker interactively.

C:\Users\andrewt>docker run -it --cap-add=SYS_PTRACE -v /c/Users/andrewt:/root comp1511/sh

Welcome to the COMP1511 Docker command-line tools & scripts container

You can fetch any recent changes to autotest files from CSE (1-2Mb).
by running: update_files

You can also fetch the latest version of this image (beware can be 100+Mb
if there have been major changes) by running:
docker pull comp1511/sh

Enter your zid: 5555555
Storing z5555555 in /root/.zid
You don't seem to have a ssh key.

Assumin this is your own computer you might like to create a ssh key
by running this command (just hit return for the questions):

ssh-keygen

You can then copy it to CSE using this command:

ssh-copy-id z5555555@cse.unsw.edu.au
pwd
/root
Docker$ id
uid=0(root) gid=0(root) groups=0(root)
Docker$  perl -e 'print "Docker perl rocks!!!\n"'
Docker perl rocks!!!
Docker$ echo 'print("Docker python rocks!!!")'|python3.5
Docker python rocks!!!
Docker$ ls -l labs/lab03
total 4
-rwxr-xr-x 1 root root  100 Sep  8  2016 digits.sh
-rwxr-xr-x 1 root root  110 Sep  8  2016 echon.sh
-rwxr-xr-x 1 root root  203 Sep  8  2016 file_sizes.sh
-rwxr-xr-x 1 root root 1809 Sep  8  2016 courses.sh
Docker$ cd labs/lab03
Docker$ autotest lab03
Test digits_1 (digits.sh) - passed
Test digits_2 (digits.sh) - passed
Test digits_3 (digits.sh) - passed
Test digits_4 (digits.sh) - passed
Test digits_5 (digits.sh) - passed
Test echon_1 (echon.sh 5 hello) - passed
Test echon_2 (echon.sh 0 nothing) - passed
Test echon_3 (echon.sh 1 goodbye) - passed
Test echon_4 (echon.sh 42 answer) - passed
Test echon_5 (echon.sh 2>&1) - passed
Test echon_6 (echon.sh 1 2 3 2>&1) - passed
Test echon_7 (echon.sh hello world 2>&1) - passed
Test echon_8 (echon.sh -42 lines 2>&1) - passed
Test file_size1 (cd data_dir;../file_sizes.sh) - passed
Test challenge1 (courses.sh JAPN) - passed
Test challenge2 (courses.sh MATH) - passed
Test challenge3 (courses.sh COMP) - passed
Test challenge4 (courses.sh PHYS) - passed
Test challenge5 (courses.sh MECH) - passed
19 tests passed  0 tests failed
You'll find convenient for git and give to create an ssh key.
Docker$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
86:e3:0e:9f:0d:40:fe:69:14:9a:8a:63:94:b7:61:b3 root@f17f24b3acb7
The key's randomart image is:
+---[RSA 2048]----+
|                 |
|                 |
|    . .          |
|  .o o o         |
| o == + S        |
|..o.== +         |
|o..E. *          |
|..   = +         |
|      + .        |
+-----------------+
Docker$ ssh-copy-id z5555555@cse.unsw.edu.au
RSA key fingerprint is 23:d5:37:a9:29:3c:b8:4f:01:e6:ae:93:82:6c:22:8c.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
z5555555@cse.unsw.edu.au's password:
Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'z9300162@cse.unsw.edu.au'"
and check to make sure that only the key(s) you wanted were added.
Docker$ cat /root/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCtkXx5F6zVcym6utNmT78P4vC3EvBmhsnXAeyDICWYVz2pR/REPiOF5tSpsGX0TJLiOcl2S7PW2rRbwBLPnLL8MoxBp9xbF5CZ6kKMtvajUB+gJU76QRxQOF+tawIkztRYuVY2pmzqjMGTduD0IS8roOxhKoBMnTrm7bjACO0ic5U8+6a91nq/0gOGvQ5z2BE9BrO9RuBrQxIBabiz5y3phvk0hfXc8gTGGHJi8HoQXWQMIJxTVme6NxQAXL5OiTbXI8KEMfnJDNHzCoZC3xTXw8WUW80xqGsYN/GF0Vc+p0zL0/ieeEphLNDPDs1LbrDj6TxksomdOvbK8GpymJ6z root@f17f24b3acb7
The ssh-copy-id command will have added your ssh key to the .ssh/authorized_keys file for your CSE account. This will make it easy for you run give from the container.
Docker$ give COMP1511 lab01 bad_pun.c bird.c kangaroo.c
Uploading to a temporary directory at CSE: bad_pun.c bird.c kangaroo.c
Warning: Permanently added 'zappa.cse.unsw.edu.au,129.94.242.68' (RSA) to the list of known hosts.
Upload completed
Running give COMP1511 lab03 bad_pun.c bird.c kangaroo.c
Session: 17s1
...