School of Physics, Mathematics, and Computing 
Not logged in (login)
help2002

This forum is provided to promote discussion amongst students enrolled in CITS2002 Systems Programming.

Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!" followup message.

How do I ask a good question?
 
Options:
RSS cloud
Jump to:

lab 1

1 of 1097 articles shown, currently no other people reading this forum.
photo
From: Malcolm M.
Date: Fri 6th Aug 2021, 11:20pm
Actions: 
Login-to-reply

"Christopher McDonald" <ch*i*.*c*o*a*[email protected]*a*e*u*a*> wrote:

> ANONYMOUS wrote:
>  
> > In lab 1, I have managed to get ubuntu working given the instructions on the unit 
> > page, but upon attempting lab 1, I didn't really know how to access the rotate.c file 
> > in the terminal. I tried copy and pasting the C code into a text editor and calling 
> > the file 'rotate.c' but it is just telling me there is no such file or directory 
> > restraining me to not yet start the lab. Is there something I am missing? I feel like 
> > I am very close to getting it. any help would be greatly appreciated.
> 
> Hi,
> 
> This a really a more general issue about how to access your Windows or macOS files while working 
> inside docker+Linux.   Until familiarity grows, you'll probably find the following way easiest, as 
> it:
> 
>   - gives you the ability to read and write your local files while in docker,
>   - allows you to use your standard browser to download files (such as rotate.c)
>   - (assuming that you're performing backups) files created/changed in docker will be backed up.
> 
> I've tested this on macOS, but not Windows (anyone else able to test this??)
> 
> Using the Docker Desktop (GUI) we first need to indicate that docker is permitted to access your 
> local files (only required once):
> 
>    - DockerDesktop > Settings(button) > Resources > FileSharing > add(+) the name of your local directory
>    - Apply & Restart
> 
> (on my Mac I added /Users/chris, which is my full home directory, but you could set just a
> sub-directory for specific CITS2002 work).
> 
> Now, when you run docker, we need to add some command-line arguments:
> 
>   docker run --rm -it -v /Users/chris:/home/chris -w /home/chris --name ubuntu ubuntu:latest bash
> 
> (use your name, ANONYMOUS, not chris :-)
> 
> Now, when your Linux shell starts in docker, your present working directory will be /home/chris, 
> rather than the root directory,  / , a much safer place to work, and you should able to see your 
> existing files using  'ls'.
> 
> _____
> Hope this helps.

My windows 10 docker (WSL2) doesn't have a "fileSharing" option in the dockersDesktop > Settings > resources 
dialog (see 1st screenshot). also, "wget https://teaching.csse.uwa.edu.au/units/CITS2002/labsheets/rotate.c" 
in the docker terminal  results in an error (2nd screenshot) 

Attempting the "Shift / Right click / Open Linux Terminal" trick and using "cp rotate.c ~/CITS2002/lab01" 
worked, but only inside the shell it opened (the docker shell couldn't see rotate.c) (2nd screenshot)

I'm not sure if this is related or not, but I also noticed that each time I type "exit" in the docker linux 
shell command interface (and return to the windows command prompt), when i return to the linux command via 
the "run -it --rm --name myubuntu myubuntu bash" command, everything disappears (e.g. the bash_profile file, 
the entire "CITS2002" directory, all the new user "whoops!" files, etc.). Why does this happen? Is there some 
way to use the docker linux command instance but not lose all my files every time we exit the docker linux 
command mode?  Barring that, is it possibly better to just use the "right click -> open linux shell here" 
option to gain access to linux command window that we should be using to start on the lab work and 
potentially the rest of the projects for the semester?

Related articles

lab 1 (all 12) RSS
├─ original   Wed 4th Aug 2021, 8:55pm, ANONYMOUS
├─ reply 1   Thu 5th Aug 2021, 5:45am, Christopher M.
├─ reply 2   Thu 5th Aug 2021, 10:47am, ANONYMOUS  O.P.
├─ reply 3   Thu 5th Aug 2021, 2:53pm, Christopher M.
├─ reply 4   Thu 5th Aug 2021, 8:48pm, Amitava D.
├─ reply 5   Fri 6th Aug 2021, 10:55am, ANONYMOUS  O.P.
├─ reply 6   Fri 6th Aug 2021, 1:15pm, ANONYMOUS
├─ reply 7   Fri 6th Aug 2021, 2:46pm, Christopher M.
├─ reply 8   Fri 6th Aug 2021, 2:48pm, Christopher M.
├─ THIS   Fri 6th Aug 2021, 11:20pm, Malcolm M.
├─ reply 10   Fri 6th Aug 2021, 11:22pm, Malcolm M.
└─ reply 11   Sat 7th Aug 2021, 6:35am, Christopher M.
This Page


Program written by: [email protected]
Feedback welcome
Last modified:  8:37am Nov 14 2021