/Inception

42 Wolfsburg project. System Administration related exercise using Docker.

Primary LanguageShell

WHAT IS DOCKER?

Docker is a platform that allows building, deploying, and running containerized applications. It enables you to deploy your software easier no matter the machine as everything that software needs is in the docker container.

WHAT IS DOCKER COMPOSE?

It is a tool that helps you to run and manage multiple container applications.

DIFFERENCES BETWEEN VM AND DOCKER CONTAINER: https://www.freecodecamp.org/news/docker-vs-vm-key-differences-you-should-know/

1STEP: Establish SSH connection.

===== ?The reason for SSH connection is to be able to copy and paste information from the host to the virtual machine easily ====

  1. Establish ssh connection from VM to WSL 2 environment and puTTY.
  • sudo apt install OpenSSH-server
  1. Check if it is running
  • sudo systemctl status ssh
  • image
  • it is going to look something like this.
  1. Enable the ufw firewall by
  • sudo ufw enable
  1. You want to open the sshd_config file and add your port.
  • sudo nano /etc/ssh/sshd_config It will look something like this in my case I want to connect through 22 ports to the vm. image Then ctrl x; ctrl y; enter to save it.
  1. Then allow the port through the ufw firewall by:
  • sudo ufw allow 22
  1. To check if it was successful you can use sudo ufw status and you should see your port. image
  2. After that you can go to vm settings > network > advanced > port forwarding image You want to add the guest port the port 22 that you have created and then for host another port.

====== Connecting to the VM through SSH (Windows Putty) ===================

  1. Open the Putty. For hostname in the usual case add localhost and for Port add the host port in my case 2222. image

  2. You will arrive at the screen asking you to log in where you should put in the username and password of the VM image image

----- And you just successfully accessed the VM through SSH ------

====== Connecting to the VM through SSH (WSL2) or 42Wolfsburg machines ===================

  1. You want to check the file where you will see a nameserver of your wsl2 you have to use it instead of localhost. image
  2. To ssh connect to your virtual machine just type:
    • ssh klukas@172.31.112.1 -p 2222 image

----- And you just successfully accessed the VM through wsl2 ssh (P.S Just make sure you have OpenSSH installed from step 1) ------

2STEP: download and install git ===>

  1. sudo apt install git to install git
  2. Generate SSH key. -- ssh-keygen -t rsa
  3. cat /home/klukas("your username")/.ssh/id_rsa.pub and copy your public key to GitHub >> Settings >> SSH and GPG keys

----- And now voila you connected your GitHub with your VM and the same has to be done for school git -----------------------------

3STEP: get the docker engine in your VM for my virtual machine I use Ubuntu so I followed the instructions on how to install docker-engine using apt from the official docker website:

https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository

4STEP: clone your Inception git repository.

5STEP: Do not forget to have make installed: sudo apt install make

6STEP: Check if docker-compose is installed by: docker-compose --version

6.5: If docker-compose is not there instal it by : $ sudo apt-get update
$ sudo apt-get install docker-compose-plugin $ docker compose version

  • Then add your user to docker group by: $ sudo usermod -aG docker $USER $ newgrp docker
  • Check that you are in docker group by running groups you should see docker group: $groups 6STEP: You want to allow 443 port for https in ufw firewall. sudo ufw allow 443

7STEP: Repeat the step where you allowed port 22 in Virtual machine settings and set Host port 443 to communicate with VM port 443 image