Group Name: NetRascal
Team Mates:
- Mohamad Syafiq Asyraf Bin Bharudin (2116239)
- Ammar Hazir Bin Annas (2116043)
- Amir Hamzah Bin Ibrahim (2116513)
- You are allowed to have 3 group members.
- When you complete the assignment, make sure to submit the repository link of your cloned project. Make sure all the files are as what you aspect in your repository.
- Answer all questions in the README.md, in your own repository. Either use the online VSCode, terminal or github to edit. Answers are expected where you see Fill answer here.
- Learn how to use markdown. https://www.w3schools.io/file/markdown-introduction/
-
First thing you need in doing this assignment is to have a github account. Make sure to sign up at https://www.github.com
-
The second thing you need is to fork the Net&Sys Assignment repository in your own github account.
- Go to https://github.com/ZainabBashi/NatSysProject and click fork to copy the project into your own repository
- Make sure that the new fork is now in your own repository
Questions:
- What is the link of the fork Net&Sys Assignment in your repository. (1 mark)
- How many files and folders are in this repository. (1 mark)
1 folder with 6 png files (images) and 1 markdown file.
- The next thing that we will be doing is exploring codespaces. First of all, read about codespaces https://docs.github.com/en/codespaces/overview#what-is-a-codespace
- Then go to the link https://github.com/codespaces and we shall start a new codespace.
- Click on New codespace.
- Choose your own Net&Sys Assignment repository to start your codespace.
- Once you have created you codespace, you will see the following. You might already be familiar with this, since it will look similar to VSCode.
- You will see the README file file. One is a preview of how it looks like on the web, and the other is the editing view in markdown language.
- Edit the README file. Make sure you have your group details correct, ie, group name and team members along with their matric Numbers.
- Once you have finish editing, click File->Save or ctrl-s to save it.
- After saving, you will notice an M or U next to your file. You will need to commit any changes, whenever you make changes so that it is uploaded to the github repository.
- Click on the source control, hint: its on the left side panel, and it will list down the files that have been modified or updated. Click on commit. It will then ask you "Would you like to stage all your changes and commit them directly?" Just say yes, and a new tab will appear. Type a message to log what you have done, and click on the check mark.
- After that, sync the changes to the main repository.
- Make sure to commit and sync your files to the main repository, or else, your work will be lost since it is not saved into the main repository when you submit your project.
Questions:
- What is default OS used to run the virtual environment for codespaces. (1 mark)
Ubuntu Linux.
- What are the two options of RAM, disk and vcpu configuration you can have in running codespaces . (1 mark)
4-core 8GB RAM & 32GB Disk - 8-core 16GB RAM & 64GB Disk
- Why must we commit and sync our current work on source control? (1 mark)
By committing and syncing work regularly, we can maintain a robust, collaborative, and safe development environment. This allows us to track the evolution of our codes, changes made, trigger automated tests and deployments ensuring that our code is continuously tested and integrated with other changes (CI/CD pipelines), offers branching feature which allows us to develop new ideas without affecting codebase (master branch) as well as creating backup of our changes if something wrong happen.
- Look at the TERMINAL tab. Explore and run commands according to the questions below.
- You can include your answers as images, or cut and paste the output here. If you are cutting and pasting your answers, wrap your answers in the codeblock clause in markdown. For example, if i run the command whoami the the output would look like the one below.
@joeynor ➜ /workspaces/OSProject (main) $ whoami
codespace
Questions:
Look at the TERMINAL tab. Run the following commands and provide the output here.
- Run the command pwd . (1 mark) .
- Run the command cat /etc/passwd . (1 mark)
- Run the command df . (1 mark)
- Run the command du . (1 mark)
- Run the command ls . (1 mark)
- Run the command ls -asl . (1 mark)
- Run the command free -h . (1 mark)
- Run the command cat /proc/cpuinfo . (1 mark)
- Run the command top and type q to quit. (1 mark)
- Run the command uname -a. (1 mark)
- What is the available free memory in the system. (1 mark)
4.81Gi
- What is the available disk space mounted on /workspace. (1 mark)
14627556
- Name the version and hardware architecture of the linux Virtual environment. (1 mark)
Version: #22~22.04.1-Ubuntu SMP
Arch: x86_64 - What is the difference between ls vs ls -asl. (1 mark)
ls: list the directory contents
ls -asl: list directory contents including dot files (.) together with their allocated size, in blocks and print them using a long listing format - What is the TLB size of the Virtual CPU. (1 mark)
2560 4K pages
- What is the CPU speed of the Virtual CPU. (1 mark)
2663.776MHz
- What is the top running process that consumes the most CPU cycles. (1 mark)
node
- At the terminal, run a linux instance. By typing the following command.
docker pull debian
docker run --detach -it debian
- This will run the debian container. To check if the debian container is running, type
@joeynor ➜ /workspaces/OSProject (main) $ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f65be1987f84 debian "bash" 4 minutes ago Up 4 minutes romantic_jackson
- Keep note of the name used by your container, this is usually given random names unless you specify your own name. Now run a bash command on the container. Make sure you use the name of your container instead of the one shown here.
docker exec -i -t romantic_jackson /bin/bash
- Create a file on the container. First you must make sure you are in the bash command prompt of the container. The container is new, and does not have any software other than the debian OS. To create a new file, you will need an editor installed. In the bash shell of the container, run the package manager apt-get to install nano text editor.
root@f65be1987f84:~# apt-get update
root@f65be1987f84:~# apt-get install nano
root@f65be1987f84:~# cd /root
root@f65be1987f84:~# nano helloworld.txt
-
Edit your helloworld.txt, create your messsage and save by typing ctrl-X. Once saved, explore using the container to see where the file is located. Then exit the shell, by typing exit.
-
Stop the container and run docker ps -a, and restart the container again. Is your file in the container still available?
@joeynor ➜ /workspaces/OSProject (main) $ docker stop romantic_jackson
@joeynor ➜ /workspaces/OSProject (main) $ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f65be1987f84 debian "bash" 19 minutes ago Exited (137) 18 seconds ago romantic_jackson
@joeynor ➜ /workspaces/OSProject (main) $ docker restart romantic_jackson
- Stop the container and delete the container. What happened to your helloworld.txt?
@joeynor ➜ /workspaces/OSProject (main) $ docker stop romantic_jackson
@joeynor ➜ /workspaces/OSProject (main) $ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f65be1987f84 debian "bash" 19 minutes ago Exited (137) 18 seconds ago romantic_jackson
@joeynor ➜ /workspaces/OSProject (main) $ docker rm romantic_jackson
Questions:
- Are files in the container persistent. Why not?. (1 mark)
Containers use ephemeral storage (by default), which means the file system inside the container is temporary. When the container is removed, all the data stored in the container's file system is also deleted.
- Can we run two, or three instances of debian linux? . (1 mark)
Yes
- In the previous experiment, you might have notice that containers are not persistent. To make storage persistent, you will need to mount them. At the terminal, create a new directory called myroot, and run a instance of debian linux and mount myroot to the container. Find out the exact path of my root, and mount it as the root folder in the debian container.
- Create a file in /root on the container, the files should also appear in myroot of your host VM.
@joeynor ➜ /workspaces/OSProject (main) $ mkdir myroot
@joeynor ➜ /workspaces/OSProject (main) $ cd myroot/
@joeynor ➜ /workspaces/OSProject/myroot (main) $ pwd
/workspaces/OSProject/myroot
@joeynor ➜ /workspaces/OSProject/myroot (main) $ docker run --detach -it -v /workspaces/OSProject/myroot:/root debian
Questions:
- Check the permission of the files created in myroot, what user and group is the files created in docker container on the host virtual machine? . (2 mark)
user: root
group: root - Can you change the permission of the files to user codespace. You will need this to be able to commit and get points for this question. (2 mark)
//use sudo and chown
sudo chown -R codespace:codespace myroot
- Create a directory called webpage in your host machine
- Inside the directory, create a page index.html, with any content you would like
- Then, run the apache webserver and mount the webpage directory to it. Hint:
## the -p 8080:80 flag points the host port 8080 to the container port 80
docker run --detach -v /workspaces/OSProject/webpage:/usr/local/apache2/htdocs/ -p 8080:80 httpd
- If it works, codespace will trigger a port assignment and provide a URL for you to access your webpage like the one below.
-
You can also see the Port in the PORTS tab, next to the terminal tab.
-
You can then access your website by adding an index.html towards the end of your url link, like the one below.
Questions:
- What is the permission of folder /usr/local/apache/htdocs and what user and group owns the folder? . (2 mark)
Permission: drwxrwxrwx+
User: 1000 (refers to codespace)
Group: 1000 (refers to codespace) - What port is the apache web server running. (1 mark)
8080
- What port is open for http protocol on the host machine? (1 mark)
80
- In docker, you can create your own private networks where you can run multiple services, in this part, we will create two networks, one called bluenet and the other is rednet
- Run the docker create network to create you networks like the ones below
## STEP 1:
## Create Networks ##
docker network create bluenet
docker network create rednet`
## STEP 2: (automatically running)
## Create (1) Container in background called "c1" running busybox image ##
docker run -itd --net bluenet --name c1 busybox sh
docker run -itd --net rednet --name c2 busybox sh
Questions:
- Describe what is busybox and what is command switch --name is for? . (2 mark)
It is a software suite that provides several Unix utilities in a single executable file. It is often referred to as "The Swiss Army Knife of Embedded Linux" due to its versatility and compact size. BusyBox combines tiny versions of many common UNIX utilities into a single small executable, making it ideal for environments with limited resources, such as embedded systems, minimal Docker containers, and bootable rescue disks. Command --name is used to specify a name of an instance.
- Explore the network using the command
docker network ls
, show the output of your terminal. (1 mark) - Using
docker inspect c1
anddocker inspect c2
inscpect the two network. What is the gateway of bluenet and rednet.? (1 mark)c1: 172.18.0.1
c2: 172.19.0.1 - What is the network address for the running container c1 and c2.
c1: 172.18.0.0
c2: 172.19.0.0 - Using the command
docker exec c1 ping c2
, which basically issue a ping from container c1 to c2. Are you able to ping? Show your output . (1 mark)
- Let's try this again by creating a network to bridge the two containers in the two subnetworks
docker network create bridgenet
docker network connect bridgenet c1
docker network connect bridgenet c2
docker exec c1 ping c2
- Make sure to commit all changes on your source control, and make sure your source control is sync to the repository.
- Check your repository link, to see if all the files and answers are included in the repository.
- Submit through italeem, by providing the link to your repository.
- Due by 30 May, 2024