Wednesday, July 25, 2018

Install & configure docker on a fresh Linux OS

I am going to describe how to install docker & explain those necessary command.

Step 1: First of all we need to update our os with the latest packages.
Run:
 sudo apt-get update  
Key points:
sudo − The sudo command is used to ensure that the command runs with root access.
apt-get - update the OS with the latest packages from the Internet on to the Linux system.
update − The update option is used ensure that all packages are updated on the Linux system.


Step 2: Now time to add some certificates & transfer protocols, it will be required to work with the Docker site later on to download the necessary Docker packages.
Run:
 sudo apt-get install apt-transport-https ca-certificates  
Key points:
apt-transport-https - https download transport for APT. This package enables the usage of 'deb https://foo distro main' lines. in the /etc/apt/sources.list so that all package managers using the. libapt-pkg library can access metadata and packages available in sources. accessible over https (Hypertext Transfer Protocol Secure).
ca-certificates - It is a digital certificate that is used to verify the identity of 3rd parties, and encrypt data between you and said 3rd party.

Step 3: This step is to add the Docker’s official GPG GPG key. This key is required to ensure that all data is encrypted when downloading the necessary packages for Docker.
Run:
 sudo apt-key adv \ --keyserver hkp://ha.pool.sks-keyservers.net:80 \ --recv-keys 58118E89F3A912897C070ADBF76221572C52609D   
Key points:
The following command will download the key with the ID 58118E89F3A912897C070ADBF76221572C52609D from the keyserver hkp://ha.pool.sks-keyservers.net:80 and adds it to the adv keychain. Please note that this particular key is required to download the necessary Docker packages.
Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88, by searching for the last 8 characters of the fingerprint.
Run:
 sudo apt-key fingerprint 0EBFCD88  
Returns as:
 pub  4096R/0EBFCD88 2017-02-22  
    Key fingerprint = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88  
 uid         Docker Release (CE deb) <docker@docker.com>  
 sub  4096R/F273FCD8 2017-02-22  

Step 4: Next, depending on the version of ubuntu you using, you need to add the relevant repository to the docker.list for the apt package manager so that it will be able to detect the docker packages from the docker site & download them accordingly.
Run:
 sudo add-apt-repository \  
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \  
   $(lsb_release -cs) \  
   stable"  
Use the following command to set up the stable repository. You always need the stable repository, even if you want to install builds from the edge or test repositories as well. To add the edge or test repository, add the word edge or test (or both) after the word stable in the commands below.
Note: The lsb_release -cs sub-command below returns the name of your Ubuntu distribution, such as xenial. Sometimes, in a distribution like Linux Mint, you might need to change $(lsb_release -cs) to your parent Ubuntu distribution. For example, if you are using Linux Mint Rafaela, you could use trusty.

Step 5: Update the apt package index.
Update packages:
 sudo apt-get update  

Step 6: Install the latest version of Docker CE
Run:
 sudo apt-get install docker-ce  
Alternative:
(If you want to install a certain version of docker ce then list that available versions in the repo, then select and install:
Listing version madison version of docker ce:
Run:
 apt-cache madison docker-ce  

To run each command of docker without 'sudo' docker will throw an error like:
 Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.27/containers/json: dial unix /var/run/docker.sock: connect: permission denied  

Solution:
The error message tells you that your current user can’t access the docker engine, because you’re lacking permissions to access the unix socket to communicate with the engine.
As a temporary solution, you can use sudo to run the failed command as root.
However it is recommended to fix the issue by adding the current user to the docker group:
Run this command in your favourite shell and then completely log out of your account and log back in (if in doubt, reboot!):
Run:
 sudo usermod -a -G docker $USER  

Reboot your pc to ensure commands are running with right permission.

Testing Step:
To test docker is running perfectly or not, Run:
 docker --version  
More testing, Run a container:
 sudo docker run hello-world  

It will for look in local if that repo is available in local or not, if not it will download it from docker hub & you are all set to go with docker! :D



Sources:

Monday, July 23, 2018

Upgrade Ubuntu OS version 14.0 / 16.04 / 18.04

We can upgrade our ubuntu os very easily with a few steps, I will mention here three step today:
  1. Using command line.
  2. Using a bootable device pendrive/harddisk/cd
  3. Using ubuntu interface



1. Using command line:
1. To upgrade to Ubuntu 18.04, first run the following command to upgrade existing software.sudo apt update && sudo apt dist-upgrade2. Then make sure you have update-manager-core package installed.sudo apt install update-manager-core3. After that, run the following command to begin the upgrade process.do-release-upgrade4. Then follow the on-screen instruction to upgrade to Ubuntu 18.04. Once the upgrade is finished, reboot your Ubuntu desktop or server. To check your Ubuntu version, run:

lsb_release -a

Output:
No LSB modules are available.


Distributor ID: Ubuntu
Description: Ubuntu 18.04 LTS
Release: 18.04
Codename: bionic

You also need to re-enable third-party repositories such as PPA because they are disabled during upgrade.


2. Using a bootable device pendrive/harddisk/cd
We will follow some steps to upgrade ubuntu os via bootable device
1. Restart your pc & keep press F12 button continiously it will open up the BIOS of you device
2. Enable boot from usb port
3. Make your pendrive/hd bootable
4. Download a version of ubuntu from the ubuntu website & put that directly in your bootabe device
5. Put the bootable device in any of your usb port & restart your pc, keep pressing F12 &  select the 6. device you want to boot from then hit enter button
6. Then follow the on-screen instruction to upgrade


3. Using ubuntu interface
1. We can update ubuntu version as easily as an android app update by os interface.

2. search for Software & Updates… then select it to open, Set 'Notify me of a new Ubuntu version' as 'For any new version'

3. Before upgrading Ubuntu you should always make sure the desktop is updated with the latest packages… This is the standard process. To update Ubuntu packages, open Dash again and search for Software Updater, then select to open it, when open it click on the 'Install Now' button.


4. Now click on ALT+F2 at once, it allows to run a ubuntu command. Run there as 'update-manager -cd' After that, it should open the upgrade wizard to upgrade Ubuntu, Click the Upgrade button to begin the wizard… follow the on-screen instructions and continue