Static IP, SSH, Environment Variables, Mounting drives, Permissions and directories(Part 2)

In the last section we installed kubuntu19 and setup docker as well as docker-compose. In Part 2 we will be doing the following things:

  1. Set up Static IP
  2. Installing Open-SSH server
  3. Setting the environment variables that'll make configuring your docker containers easier.
  4. Mounting External Drives if needed to a location. I use /media/${USER}/ExternalDriveHere.
  5. Creating directories and changing permissions to make everything communicate better

Setting Static IP:

  1. Go to terminal and type
    sudo apt install net-tools -y && ifconfig -a
  2. Make a note of the connection that has a default gateway, like 192.168.0.1,etc. You'll need the DNS Servers, and the gateway.
  3. Open Network Connections on the bottom right.
  4. Go to your active internet connection(The one that has access to your router)
  5. Edit the settings of the connection under IPv4 and set it to manual.
  6. Fill in your DNS Servers, with a comma. You can use 1.1.1.1,1.0.0.1 if you don't want to use your ISP's DNS Servers
  7. Press Add and type in the IP address it shown in ifconfig earlier, netmask will fill itself and use the gateway from ifconfig as well
  8. Press Apply and Ok. Now your local IP address will not change!

Setting up Open-SSH Server(Optional if server is not on your main computer):

  1. Open terminal and type
    sudo apt install openssh-server -y
    sudo service ssh status
  2. If it says active you can download putty on your computer.
  3. Install Putty and then open it. Connect to the IP address you set earlier, Port 22.
  4. Press connect and type in your username and password.
  5. Now you can control your server without being at it.

Setting your Environment Variables for your account:

  1. Open terminal and type
    id
  2. Get the Numbered UserID of your user and the number for docker(mine is 130)
  3. Now you need to edit your environment variable file by typing this in the terminal:
    sudo nano /etc/environment
  4. Go to the end of the file and add a few different lines
    PUID=(The ID of your user usually 1000)
    PGID=(The ID of docker group, was 130 for me)
    TZ="America/New_York"(The TZ code of which you reside)
    USERDIR="/home/USER"#fill in USER with your username
    MYSQL_ROOT_PASSWORD="password you will choose for MySQL"
    Let me show you what a completed file looks like:
    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
    PUID=1000 PGID=130 TZ="America/New_York" USERDIR="/home/mediaserver" MYSQL_ROOT_PASSWORD="123456789"
  5. Now that it is done, press ctrl+x, press y and hit enter.
  6. Logout and log back in for the changes to take effect!

External Drive Mounting(Optional):

  1. Open terminal and type
    sudo fdisk -l
  2. Find the drive you are looking for mounting that you will put media in. All you usually need is /dev/sdd2 /dev/sde1 etc.
  3. Once you know which drive you need to mount check to see if its mounted anywhere by typing
    sudo umount /dev/PARTITION_HERE
  4. Then you can mount the drive to your location of choice, mine is inside /media/USERNAME/
    sudo mount /dev/PARTITION_HERE /media/USERNAME/NAMEYOUWANT

Creating Docker directory and setting permissions!

  1. Open terminal and type
  2. 3
     
    1
    2
    3
  3. This should make a directory and set permissions to it called docker it will be located inside /home/USERNAME/docker. This is where all of your Docker files will be stored from all your different containers. Your other volumes get stored in /var/lib/docker/volumes.

Okay so now you have completed the prep work before you get started configuring docker containers! I look forward to seeing you all in Part 3.

Have a wonderful day!