How to install Minikube on Ubuntu 22.04

Minikube is a tool that makes it easy to run Kubernetes locally. Minikube runs a single-node Kubernetes cluster inside a VM on your local machine. Kubernetes quickly set up a local Kubernetes cluster on Linux, Windows, and macOS.

It is always advisable before diving into Kubernetes, you will need a minimal Kubernetes setup. Such a setup should spin up fast and integrate well with other tools.

In his tutorial, we are going to learn how to install Minikube on Ubuntu 22.04. I am going to use Docker as a containerization platform. You can either VirtualBox, Podman, KVM, etc.

Minikube is the best fit because of the following:

  • It runs on Windows, Linux, and macOS.
  • It supports the latest Kubernetes release
  • It supports multiple container runtimes i.e Containerd, KVM, Docker, Podman, etc
  • It has supports for advanced features such as Load balancing, Featuregates, and filesystems mounts.
  • It has support for Addons. Addons is a marketplace for developers to share configurations for running services on Minikube.
  • It supports CI environments

Prerequisites

To run Kubernetes effectively you need to allocate the following to Minikube on your system.

  • 2 CPUs or more
  • 2 GB of memory
  • 20 GB or more of free disk space
  • Reliable internet connections.
  • Container or virtual machine manager such as Docker, KVM, Podman, Virtual Box etc.

Related Articles

  • How to install and configure Minikube on Ubuntu 21.10
  • How to install and use Minikube on Fedora 35

Install Minikube on Ubuntu 22.04

1. Update system repositories

The first thing we need to do is to update our system repositories in order to make them up to date. Run the following command on your terminal to update our system.

$ sudo apt update && apt upgrade -y

2. Install Docker on Ubuntu 20.04

As I said from the beginning, we are going to use Docker. Check this article on How to install Docker-CE on Ubuntu 22.04

You can install Docker using the following command on your terminal.

$ sudo apt install docker.io

You need to enable and start docker so that it will start every time you boot your system.

# Enable docker
$ sudo systemctl enable docker
# Start docker
$sudo systemctl start docker 
# Check docker status
$ sudo systemctl status docker  
# Docker Status 
● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2022-01-23 15:32:26 UTC; 5min ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 8858 (dockerd)
      Tasks: 10
     Memory: 41.8M
     CGroup: /system.slice/docker.service
             └─8858 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Once Docker is installed, we need to add a user into our system because Docker runs in rootless mode.

Add a user to Docker with the following command.

# add user and add to docker group
$ sudo usermod -aG docker $USER && newgrp docker

When Docker installation is complete then it’s time to install Minikube.

3. Install Minikube on Ubuntu 20.04

In order to install the latest version release of Minikube, we are going to download it using the curl command.

$ curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb
sudo dpkg -i minikube_latest_amd64.deb

4. Start Minikube

To start using Minikube we need to start it first with the following command:

$ minikube start

You will see the following output

# output
😄  minikube v1.25.2 on Ubuntu 22.04
✨  Automatically selected the docker driver. Other choices: none, ssh
👍  Starting control plane node minikube in cluster minikube
🚜  Pulling base image ...
💾  Downloading Kubernetes v1.23.3 preload ...
    > preloaded-images-k8s-v17-v1...: 505.68 MiB / 505.68 MiB  100.00% 1.20 MiB
    > gcr.io/k8s-minikube/kicbase: 379.06 MiB / 379.06 MiB  100.00% 911.18 KiB 
🔥  Creating docker container (CPUs=2, Memory=2200MB) ...
🐳  Preparing Kubernetes v1.23.3 on Docker 20.10.12 ...
    ▪ kubelet.housekeeping-interval=5m
    ▪ Generating certificates and keys ...
    ▪ Booting up control plane ...
    ▪ Configuring RBAC rules ...
🔎  Verifying Kubernetes components...
    ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟  Enabled addons: storage-provisioner, default-storageclass
💡  kubectl not found. If you need it, try: 'minikube kubectl -- get pods -A'
🏄  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

We can check minikube version with the following command:

$ minikube version
minikube version: v1.25.2
commit: 362d5fdc0a3dbee389b3d3f1034e8023e72bd3a7

5. Install Kubectl on Ubuntu 20.04

Let’s install kubectl using binary install. We are going to use the curl command.

$ curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

Download the following checksum to validate our install

$ curl -LO "https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"

Then when installation is complete validate with the following command.

$ echo "$(

If valid you will get kubectl ok as the output.

Install Kubectl

$ sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

If you ls you will notice that kubectl changes color meaning it’s now executable.

Check if t=Kubectl is installed properly.

$ kubectl version --short 
Flag --short has been deprecated, and will be removed in the future. The --short output will become the default.
Client Version: v1.24.1
Kustomize Version: v4.5.4
Server Version: v1.23.3

Check kubectl cluster information with the following command;

$ kubectl cluster-info

If its working correctly then we will see a URL being shown

# output
Kubernetes control plane is running at https://192.168.49.2:8443
CoreDNS is running at https://192.168.49.2:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

To check configuration use kubectl config view

$ kubectl config view 

You will get a very nice json file like the one shown below.

# output
apiVersion: v1
clusters:
- cluster:
    certificate-authority: /home/nextgen/.minikube/ca.crt
    extensions:
    - extension:
        last-update: Sat, 28 May 2022 13:40:38 EAT
        provider: minikube.sigs.k8s.io
        version: v1.25.2
      name: cluster_info
    server: https://192.168.49.2:8443
  name: minikube
contexts:
- context:
    cluster: minikube
    extensions:
    - extension:
        last-update: Sat, 28 May 2022 13:40:38 EAT
        provider: minikube.sigs.k8s.io
        version: v1.25.2
      name: context_info
    namespace: default
    user: minikube
  name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
  user:
    client-certificate: /home/nextgen/.minikube/profiles/minikube/client.crt
    client-key: /home/nextgen/.minikube/profiles/minikube/client.key

In order to access your cluster using kubectl use the following command.

$ kubectl get po -A
NAMESPACE     NAME                               READY   STATUS    RESTARTS      AGE
kube-system   coredns-64897985d-hgvbk            1/1     Running   0             30m
kube-system   etcd-minikube                      1/1     Running   0             30m
kube-system   kube-apiserver-minikube            1/1     Running   0             30m
kube-system   kube-controller-manager-minikube   1/1     Running   0             30m
kube-system   kube-proxy-6c48r                   1/1     Running   0             30m
kube-system   kube-scheduler-minikube            1/1     Running   0             30m
kube-system   storage-provisioner                1/1     Running   1 (29m ago)   30m

6. Enable Kubernetes Dashboard

Kubernetes comes with a dashboard where you will manage your clusters. To enable the dashboard, use the following command:

$ minikube dashboard

Running the following command will get us the following output.

#output
🔌  Enabling dashboard ...
    ▪ Using image kubernetesui/dashboard:v2.3.1
    ▪ Using image kubernetesui/metrics-scraper:v1.0.7
🤔  Verifying dashboard health ...
🚀  Launching proxy ...
🤔  Verifying proxy health ...
🎉  Opening http://127.0.0.1:35251/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ in your default browser...

It will then open your dashboard on your default browser. You can now interact easily with your deployments.

Whenever you don’t want to start minikube dashboard on your browser, you can prefix with –url

minikube dashboard --url

7. Create a deployment and a service

A service is an abstraction that defines a logical set of Pods and a policy by which to access them. Pods are the smallest execution unit in Kubernetes. It encapsulates one or more applications. Kubernetes Pods are created and destroyed to match the desired state of your cluster. Pods are only accessible by its internal IP address within the kubernetes cluster.

Let’s make an hello-node. Follow the following steps.

Create deployment

To create a deployment we use kubectl create command

$ kubectl create deployment hello-node --image=k8s.gcr.io/echoserver:1.4

Sample output will look like this

 > kubectl.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
    > kubectl: 30.80 KiB / 44.43 MiB [>_________________________] 0.07% ? p/s     > kubectl: 46.80 KiB / 44.43 MiB [>_________________________] 0.10% ? p/s     > kubectl: 78.79 KiB / 44.43 MiB [>_________________________] 0.17% ? p/s     > kubectl: 286.79 KiB / 44.43 MiB [>_______] 0.63% 426.90 KiB p/s ETA 1m45    > kubectl: 558.79 KiB / 44.43 MiB [>_______] 1.23% 426.90 KiB p/s ETA 1m45    > kubectl: 894.79 KiB / 44.43 MiB [>_______] 1.97% 426.90 KiB p/s ETA 1m44    > kubectl: 1.61 MiB / 44.43 MiB [>_________] 3.62% 545.52 KiB p/s ETA 1m20    > kubectl: 1.61 MiB / 44.43 MiB [>_________] 3.62% 545.52 KiB p/s ETA 1m20

To view the deployments, we use kubectl get deployments

kubectl get deployments

The sample output will look like this.

NAME         READY   UP-TO-DATE   AVAILABLE   AGE
hello-node   1/1     1            1           115s

To view the pods use the kubectl get pods command.

kubectl get pods 

The sample output will look like this

NAME                          READY   STATUS    RESTARTS   AGE
hello-node-6b89d599b9-mlv7q   1/1     Running   0          5m23s

After we have created deployment we need to expose the Pod to the public internet with kubectl expose command.

kubectl expose deployment hello-node --type=LoadBalancer --port=8080

–type=LoadBalancer expose the service outside the cluster

You will get an output service/hello-node exposed.

To view the services you have created we use kubectl get services command.

kubectl get services 

This is the output you will get.

NAME         TYPE           CLUSTER-IP    EXTERNAL-IP   PORT(S)          AGE
hello-node   LoadBalancer   10.97.64.87        8080:30179/TCP   33m
kubernetes   ClusterIP      10.96.0.1             443/TCP          133m

To stop minikube virtual machine we use minikube stop

minikube stop

To delete minikube virtual machine use minikube delete

minikube delete

To stop and delete the services we have created above we use the following command.

$ kubectl delete service hello-node
$ kubectl delete deployment hello-node

Conclusion

We have successfully installed Minikube on Ubuntu 22.04. If you face any challenges do give us a comment and we will be happy to assist.

How to create Django Templates

In this tutorial, we will learn how to create Django models. We are going to use Django 4.0. In the previous tutorial, we saw how to create your first project. We displayed hello world in our browser.

As a recap of what we saw in the previous lesson, let’s create a new project once more.

On your terminal, we can create a new directory for our project first. Let’s call new_project

$ cd Desktop
$ sudo mkdir new_project
$ cd new_project

When you are inside the new_project folder, now is the time to install Django. As a good practice, I always advise creating a requirements.txt file so that you can store all your installed applications. So to create a requirements.txt file, go to the terminal. Remember we are at the new_project directory.

$ sudo touch requirements.txt

Now that we have the requiremets.txt file, we can now use nano or vim to write into it. I am going to use vim text editor, you can use any you prefer.

sudo vi requirements.txt

Inside django inside this file.

django~=4.0

Create a Virtual Environment

Let’s begin by creating a virtual environment. Use the following code to accomplish that.

$ sudo python3 -m venv myvenv

Myvenv here is the name of our virtual environment.

Then we need to activate our virtual environment before we can begin our project.

source myvenv/bin/activate

Please make sure you see your terminal being prefixed by the name of your terminal like this.

(myvenv) nextgen@zx-pc:~/Desktop/new_project$ 

Install Django

Let’s now install Django using the pip command inside the virtual environment. Remember the requirements.txt we created earlier, it’s now time we use it to install Django.

$ pip install -r requirements.txt
Collecting django
  Using cached Django-4.0.4-py3-none-any.whl (8.0 MB)
Collecting asgiref<4,>=3.4.1
  Using cached asgiref-3.5.2-py3-none-any.whl (22 kB)
Collecting sqlparse>=0.2.2
  Using cached sqlparse-0.4.2-py3-none-any.whl (42 kB)
Installing collected packages: sqlparse, asgiref, django
Successfully installed asgiref-3.5.2 django-4.0.4 sqlparse-0.4.2

Now that we have installed Django successfully, we can proceed to create a project.

Start Django Project

To start a Django project, use the following command inside the virtual environment.

$ django-admin startproject main .

The name of our project is main and please don’t forget the period in the end. It shows that we are creating a project in the current directory.

After we have created the project, we can now move ahead and create Django app

python manage.py startapp products 

The name of the app we are creating is products

Create Django views

A view function is a Python function that takes the web request and returns a web function. Let’s see with an example what we mean.

from django.shortcuts import render

from django.http import HttpResponse


def home_view(request):
    return HttpResponse('

Hello world

')

Inside the products app, we need to create a urls.py file where the routing logic will occur. Add this file and proceed.

from django.urls import path
from . views import home_view

urlpatterns = [
    path('', home_view, name='home'),
]

Go to main/urls.py file and create the following

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('products.urls')),
]

The next thing we need to do is to add our product name inside the settings.py file. Under installed apps, we need to add products app there like this.

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    'products.apps.ProductsConfig',# add this file 
]

To run our app use the following command inside the root of your django project. Here root is where you are having manage.py file.

$ python manage.py runserver

This is what we are going to see.

System check identified no issues (0 silenced).

You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
May 24, 2022 - 18:02:56
Django version 4.0.4, using settings 'main.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

Don’t worry about unapplied migrations we will deal with that in a while. Open your browser and use this http://127.0.0.1:8000/ to open our development server.

django view

Hurray! We have run our first Django program. If you are getting what you can see above, then we can proceed.

Creating Templates

From what we have created so far lies one big problem, here we are not in a position to render templates meaning we are not in a position to scale our project. What we ought to do is make use of templates. Here templates I mean make use of HTML files. Let’s see how we can implement this.

From the views.py file, we have what we have created above, I want us to delete return HttpResponse(‘

Hello world

’) and use return render(request, ‘html’)

from django.http import HttpResponse
from django.shortcuts import render


def home_view(request):
    return render(request, 'products/index.html')# add this file 

We need first to create a template file inside our products app. To do that, go to the products folder and create another folder and call it templates, make sure you spelled it correctly. Inside templates create an index.html file.

templates

Before we can write anything inside the index.html file, we need first to move to the settings.py file and add our template path

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            BASE_DIR / 'templates' # add this file 
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

First, let’s apply those unapplied migrations with the following command. This will populate our database.

$ python manage.py migrate
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying auth.0012_alter_user_first_name_max_length... OK
  Applying sessions.0001_initial... OK

Run python manage.py runserver again and open your browser.

Django using template

We have arrived at the same thing but this time using template form.

In the next lesson, we are going to see how to perform CRUD operations using Django.

How to install PostgreSQL 14 on Ubuntu 20.04 from the source

In this article, we are going to learn how to install and get PostgreSQL 14 up and running on an Ubuntu 20.04 server. PostgreSQL is a powerful, open-source object-relational database system that uses and extends the SQL language combined with many features that safely store and scale the most complicated data workloads.

Install PostgreSQL 14 on Ubuntu 20.04

Ubuntu comes with a default PosgreSQL in its APT repositories. To check the default in the repositories, we can use the following command.

$ sudo apt-cache search postgresql | grep postgresql

postgresql - object-relational SQL database (supported version)
postgresql-12 - object-relational SQL database, version 12 server
postgresql-client - front-end programs for PostgreSQL (supported version)
postgresql-client-12 - front-end programs for PostgreSQL 12
postgresql-client-common - manager for multiple PostgreSQL client versions
postgresql-common - PostgreSQL database-cluster manager
postgresql-contrib - additional facilities for PostgreSQL (supported version)
postgresql-doc - documentation for the PostgreSQL database management system
postgresql-doc-12 - documentation for the PostgreSQL database management system

As you can see, Ubuntu 20.04 comes with a default PostgreSQL 12.

Update system repositories

Let’s first update our repositories in order to make them up to date.

$ sudo apt update && apt upgrade -y

Install PostgreSQL dependencies

We need to have the following dependencies installed first before we can proceed to install from the source.

$ sudo apt install build-essential zlib1g-dev libreadline-dev -y

Download PostgreSQL 14 from source

Head over to postgresql ftp server to download the latest version

$ wget https://ftp.postgresql.org/pub/source/v14.2/postgresql-14.2.tar.gz

Next, we need to extarct this downloaded content.

$ tar xvfz postgresql-14.2.tar.gz

Then next we are going to cd into it then do configuration and do make and lastly sudo make install.

cd postgresql-14.2
./configure 
make
make install

Add a Postgres user

To allow us run administrative jobs we need to add a postgres user and also because we didnt install from the APT repository, its ncessary to install Postgresql-contrib first.

$ sudo apt install postgresql-contrib

Add a postgres user password with this command.

$ sudo passwd postgres 

and to switch to the postgres user use this command

$ su postgres
$ psql
psql (14.2 (Ubuntu 14.2-1ubuntu1))
Type "help" for help.

postgres=# \l
                              List of databases
   Name    |  Owner   | Encoding | Collate |  Ctype  |   Access privileges   
-----------+----------+----------+---------+---------+-----------------------
 postgres  | postgres | UTF8     | C.UTF-8 | C.UTF-8 | 
 template0 | postgres | UTF8     | C.UTF-8 | C.UTF-8 | =c/postgres          +
           |          |          |         |         | postgres=CTc/postgres
 template1 | postgres | UTF8     | C.UTF-8 | C.UTF-8 | =c/postgres          +
           |          |          |         |         | postgres=CTc/postgres
(3 rows)
                    

To check the version of the PostgreSQL installed use this command.

postgres=# SELECT version();
 version                                                      
 PostgreSQL 14.2 (Ubuntu 14.2-1ubuntu1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0, 64-bit
(1 row)

postgres=# 

Conclusion

Congratulations you have installed PostgreSQL 14 from the source.

How to install pgAdmin 4 on Ubuntu 22.04

In this tutorial guide, I will be taking you through the installation of pgAdmin 4 version 6.9 on Ubuntu 22.04.

pgAdmin 4 is a free and open-source management tool for Postgres. Its desktop runtime written in NWjs allows it to run standalone for individual users, or the web applications code may be directly deployed on a web server for use by the web browser.

pgAdmin 4 is a complete rewrite of pgAdmin, built using Python and Java

New features of pgAdmin 4 version 6.9

The following are the notable changes introduced to pgAdmin 4 version 6.9

  • The status bar was added to the Query Tool.
  • It added the capability to deploy PostgreSQL servers on EDB BigAnimal. this feature allows users to deploy PostgreSQL and EDB and Advanced Server on the EDB BigAnimal cloud.
  • Introduced port Query tool to react. This tool is a major upgrade to the status bar added to Query Tool.
  • It added the added options to ignore owner and ignore whitespace on the schema diff panel.
  • It added support to Azure AD OAUTH2 authentication.
  • Relocate GIS button to the left side of the results table.
  • It ensures that row numbers should be visible in the view when scrolling horizontally.
  • It ensures that columns should always be visible in the import and export dialogs.

Install pgAdmin 4 on Ubuntu 22.04

1. Update system repositories

The first thing to do is to update repositories to make them up to date.

$ sudo apt update && apt upgrade -y

2. Add pgAdmin 4 repository to Ubuntu 22.04

pgAdmin 4 is available from Debian packages. We just need to add pgAdmin 4 to our Ubuntu repository.

# gpg key 
$ curl  -fsSL https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/pgadmin.gpg

Add repo to Debian packages like this

$ sudo sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list'

3. Install pgAdmin 4

To install pgAdmin 4, first, run system updates again to update all repositories for changes introduced to take effect.

$ sudo apt update -y
$ sudo apt install pgadmin4

Sample output

# output
The following packages were automatically installed and are no longer required:
  linux-headers-5.15.0-25 linux-headers-5.15.0-25-generic
  linux-image-5.15.0-25-generic linux-modules-5.15.0-25-generic
  linux-modules-extra-5.15.0-25-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libapache2-mod-wsgi-py3 pgadmin4-desktop pgadmin4-server pgadmin4-web
  postgresql-client postgresql-client-14 postgresql-client-common
Suggested packages:
  postgresql-14 postgresql-doc-14
The following NEW packages will be installed:
  libapache2-mod-wsgi-py3 pgadmin4 pgadmin4-desktop pgadmin4-server
  pgadmin4-web postgresql-client postgresql-client-14 postgresql-client-common
0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 195 MB of archives.
After this operation, 4,456 kB of additional disk space will be used.
Do you want to continue? [Y/n] 

To start pgadmin4 head over to Ubuntu 22.04 dock and click on show applications and search for pgadmin4. you need to set password so that you will use this password while working with PostgreSQL services.

pgAdmin4 dashboard

How to install Vivaldi browser on Fedora 36

Vivaldi browser is a freeware, cross-platform web browser developed by Vivaldi Technologies. It has a minimalistic user interface with basic icons and fonts and, an optionally color scheme that changes based on the background and design of the web page being visited.

Features of Vivaldi browser

  • It has a built-in ad blocker, pop-up blocker, and tracker blocker. It helps block intrusive ads and makes the browser much faster which many users want.
  • It comes with a built-in email client with IMAP and POP3 support.
  • The browser can be used as a feed reader to save RSS and Atom feeds.
  • It has the ability to stack and tile tabs, annotate web pages, and add notes to bookmarks.
  • It supports numerous mouse gestures for actions like tab switching and keyboard activation
  • It supports hibernation for both individual tabs and for tab stacks, hence freeing resources while the user does not actively use those tabs.
  • It has translate features that can translate any web page with a single click with a built-in, private translation tool.

Prerequisites

  • Have a user with sudo privileges.
  • Have Fedora 36 up and running.
  • Have basic knowledge of terminal

Install Vivaldi browser on Ubuntu 22.04

1. Update system repositories

To start installing Vivaldi, we can first make our repositories up to date by doing an update and upgrade where necessary.

$ sudo dnf update -y

2. Add Vivaldi Repository to Fedora 36

To install Vivaldi, there is an RPM repository provided for this, so what we need to do is to add this repository to our system using the following.

$ sudo dnf install dnf-utils

You will see the following output

Dependencies resolved.
=============================================================================================================================================
 Package                           Architecture                   Version                              Repository                       Size
=============================================================================================================================================
Installing:
 dnf-utils                         noarch                         4.2.0-1.fc36                         updates                          37 k

Transaction Summary
=============================================================================================================================================
Install  1 Package

Total download size: 37 k
Installed size: 23 k
Is this ok [y/N]: y
Downloading Packages:
dnf-utils-4.2.0-1.fc36.noarch.rpm                                                                            109 kB/s |  37 kB     00:00    
---------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                         42 kB/s |  37 kB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                     1/1 
  Installing       : dnf-utils-4.2.0-1.fc36.noarch                                                                                       1/1 
  Running scriptlet: dnf-utils-4.2.0-1.fc36.noarch                                                                                       1/1 
  Verifying        : dnf-utils-4.2.0-1.fc36.noarch                                                                                       1/1 

Installed:
  dnf-utils-4.2.0-1.fc36.noarch                                                                                                              

Complete!

Then we need to add the repository with this command.

$ sudo dnf config-manager --add-repo https://repo.vivaldi.com/archive/vivaldi-fedora.repo

Once added we can then proceed to install the Vivaldi browser stable version with the following command.

$ sudo dnf install vivaldi-stable -y

You will have to allow the key generation process during installation.

vivaldi                                                                                                       23 kB/s | 3.1 kB     00:00    
Importing GPG key 0xC27AA466:
 Userid     : "Vivaldi Package Composer KEY07 "
 Fingerprint: CB63 144F 1BA3 1BC3 9E27 79A8 FEB6 023D C27A A466
 From       : https://repo.vivaldi.com/archive/linux_signing_key.pub
Is this ok [y/N]: y

Then the installation will proceed to completion. You will get the following

 Package                                        Architecture       Version                                         Repository           Size
Installing:
 vivaldi-stable                                 x86_64             5.2.2623.48-1                                   vivaldi              83 M
Installing dependencies:
 adwaita-cursor-theme                           noarch             42.0-1.fc36                                     fedora              622 k
 adwaita-icon-theme                             noarch             42.0-1.fc36                                     fedora              4.2 M
 alsa-lib                                       x86_64             1.2.6.1-4.fc36                                  fedora              499 k
 at-spi2-atk                                    x86_64             2.38.0-4.fc36                                   fedora               86 k
 at-spi2-core                                   x86_64             2.44.1-1.fc36                                   updates             178 k
 atk                                            x86_64             2.38.0-1.fc36                                   fedora              272 k
 avahi-glib                                     x86_64             0.8-15.fc36                                     fedora               15 k
 avahi-libs                                     x86_64             0.8-15.fc36                                     fedora               68 k
 bluez-libs                                     x86_64             5.64-1.fc36                                     fedora               84 k
 cairo                                          x86_64             1.17.6-1.fc36                                   fedora              675 k
 cairo-gobject                                  x86_64             1.17.6-1.fc36                                   fedora               18 k
 cdparanoia-libs                                x86_64             10.2-39.fc36                                    fedora               54 k
 colord-libs                                    x86_64             1.4.6-1.fc36                                    fedora              233 k
 cups-libs        

Conclusion

And we have successfully installed the Vivaldi browser on Fedora 36. Enjoy the greatest features you can get on this awesome browser. For more information check Viladi documentation.

How to install go 1.18 on Fedora 36

Golang is an open-source programming language that is easy to learn and use. It is built-in concurrency and has a robust standard library. It is reliable, builds fast, and efficient software that scales fast.

Its concurrency mechanisms make it easy to write programs that get the most out of multicore and networked machines, while its novel-type systems enable flexible and modular program constructions.

Go compiles quickly to machine code and has the convenience of garbage collection and the power of run-time reflection.

In this guide, we are going to learn how to install golang 1.18 on Fedora 36.

There is so much work in progress with all the documentation so keep checking the go documentation for any changes.

The changes that have been introduced are the following:

  • Go 1.18 includes an implementation of generic features. This includes backward-compatibility changes to the language.
  • The syntax for function and type declarations now accepts type parameters.
  • Parameterized functions and types can be instantiated by following them with a list of type arguments in square brackets.
  • The syntax for interface types now permits the embedding of arbitrary types and unions.
  • The new predeclared identifier is an alias for the empty interface. It may be used instead of interface {}.
  • The go 1.18 compiler now correctly reports declared but not used errors for variables that are set inside a function literal but are never used.
  • The go 1.18 compiler now reports an overflow when passing a rune constant expression.
  • Go 1.18 introduces the new GOAMD64 environment variable which selects a version of AMD64 architecture.
  • Go 1.18 get no longer builds or installs packages in the module-aware mod.
  • gofmt now reads and formats input files concurrently with a memory limit proportional GOMAXPROCS.
  • The vet tool is updated to support generic code.
  • The garbage collector now includes non-hip sources of garbage collector work when determining how frequently to run.

Related Articles

Installing Go 1.18 on Ubuntu 20.04

1. Run system updates

To begin with, we need to run system updates in order to make our current repositories up to date. To do so we need to run the following command on our terminal.

sudo dnf update -y

When updates are complete, go ahead to download go from its download page.

2. Installing Go

To install go we need to download it from go download page. we are going to download the beta release. We are going to use the curl command to download.

$ curl -LO https://go.dev/dl/go1.18.2.linux-amd64.tar.gz

when the download is complete, extract the archive downloaded to your desired location. I will be using /usr/local directory.

$ sudo tar -C /usr/local -xzf go1.18.2.linux-amd64.tar.gz

After extraction is complete move ahead and set up the go environment.

3. Setting Go Environment

To set up go environment we need to define the root of golang packages. We normally use GOROOT and GOPATH to define that environment. We need to set up the GOROOT location where the packages are installed.

$ export GOROOT=/usr/local/go

Next, we will need to set up the GOPATH. Let’s set up GOPATH in the $HOME/go directory.

$ export GOPATH=$HOME/go

Now we need to append the go binary PATH so that we can access the program system-wide. Use the following command.

$ export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

To apply the changes we have made above, run the following command:

source ~/.bashrc

Lastly, we can do the verification with the following;

go version
go version go1.18.2 linux/amd64

Let’s create a program to check all our settings. We will create a simple one.

Create a file main.go on the main directory.

touch main.go

On your favorite text editor do the following

sudo vi main.go

Insert the below code

$ package main

import "fmt"

func main(){
        fmt.Println("Hello Fedora 36")
}

To run the program use the following command;

go run main.go
Hello Fedora 36

Conclusion

Now you know how to install golang 1.18 in Fedora 36. You can consult the go documentation in case you have any problems.

How to install Vivaldi Browser on Ubuntu 22.04

Vivaldi browser is a freeware, cross-platform web browser developed by Vivaldi Technologies. It has a minimalistic user interface with basic icons and fonts and, an optionally color scheme that changes based on the background and design of the web page being visited.

Features of Vivaldi browser

  • It has a built-in ad blocker, pop-up blocker, and tracker blocker. It helps block intrusive ads and makes the browser much faster which many users want.
  • It comes with a built-in email client with IMAP and POP3 support.
  • The browser can be used as a feed reader to save RSS and Atom feeds.
  • It has the ability to stack and tile tabs, annotate web pages, and add notes to bookmarks.
  • It supports numerous mouse gestures for actions like tab switching and keyboard activation
  • It supports hibernation for both individual tabs and for tab stacks, hence freeing resources while the user does not actively use those tabs.
  • It has translate features that can translate any web page with a single click with a built-in, private translation tool.

Prerequisites

  • Have a user with sudo privileges.
  • Have Ubuntu 22.04 up and running.
  • Have basic knowledge of terminal

Install Vivaldi browser on Ubuntu 22.04

1. Update system repositories

To start installing Vivaldi, we can first make our repositories up to date by doing an update and upgrade where necessary.

sudo apt update && apt upgrade -y

2. Import public GPG key

We need to import a public GPG key in order to allow for the verification of apt packages in our system. To import it we are going to use the wget command on our terminal

wget -qO- https://repo.vivaldi.com/archive/linux_signing_key.pub | gpg --dearmor | sudo dd of=/usr/share/keyrings/vivaldi-browser.gpg

3. Add Vivaldi repository

After the GPG key has been added we need to add the Vivaldi repository to our own repository on Ubuntu.

echo "deb [signed-by=/usr/share/keyrings/vivaldi-browser.gpg arch=$(dpkg --print-architecture)] https://repo.vivaldi.com/archive/deb/ stable main" | sudo dd of=/etc/apt/sources.list.d/vivaldi-archive.list

4. Install Vivaldi on Ubuntu 22.04

To install Vivaldi first run the system update and then run install.

$ sudo apt update
Ign:6 https://repo.vivaldi.com/archive/deb stable InRelease
Get:7 https://repo.vivaldi.com/archive/deb stable Release [3,840 B]
Get:8 https://repo.vivaldi.com/archive/deb stable Release.gpg [833 B]
Get:9 https://repo.vivaldi.com/archive/deb stable/main amd64 Packages [1,773 B]
Fetched 277 kB in 3s (91.2 kB/s)      
Reading package lists... Done

After the update is complete, run the installation command.

$ sudo apt install vivaldi-stable

You will see the output like this.

Output
The following NEW packages will be installed:
  vivaldi-stable
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 87.8 MB of archives.
After this operation, 309 MB of additional disk space will be used.
Get:1 https://repo.vivaldi.com/archive/deb stable/main amd64 vivaldi-stable amd64 5.2.2623.41-1 [87.8 MB]
Fetched 87.8 MB in 22s (3,970 kB/s)                                            
Selecting previously unselected package vivaldi-stable.
(Reading database ... 210907 files and directories currently installed.)
Preparing to unpack .../vivaldi-stable_5.2.2623.41-1_amd64.deb ...
Unpacking vivaldi-stable (5.2.2623.41-1) ...
Setting up vivaldi-stable (5.2.2623.41-1) ...
update-alternatives: using /usr/bin/vivaldi-stable to provide /usr/bin/x-www-bro
wser (x-www-browser) in auto mode
update-alternatives: using /usr/bin/vivaldi-stable to provide /usr/bin/gnome-www
-browser (gnome-www-browser) in auto mode
update-alternatives: using /usr/bin/vivaldi-stable to provide /usr/bin/vivaldi (
vivaldi) in auto mode
Processing triggers for desktop-file-utils (0.26-1ubuntu3) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu3) ...
Processing triggers for mailcap (3.70+nmu1ubuntu1) ...

To start using the browser go to the dock and click show applications and search for Vivaldi in the search bar.

Conclusion

We have successfully installed Vivaldi browser, you can now enjoy your privacy while browsing.

How to install Docker-CE on Ubuntu 22.04

Docker is a set of platform-as-a-service products that uses OS-level virtualization to deliver software in packages called containers. Containers are usually isolated from one another and bundled with their own software libraries and configuration files, they can communicate with each other through well-defined channels.

Docker makes it possible to get more apps running on the same old servers and also makes it easy to package and ship programs. In this tutorial am going to show you how you can install Docker-CE on Ubuntu 20.04.

Related Articles

Prerequisites

  • Make sure you have a user with sudo privileges
  • Have Ubuntu 22.04 server up and running
  • Have basic knowledge about running commands on a shell

Install Docker-ce on Ubuntu 22.04

1. Update system repositories

Let’s begin by updating our system repositories to make them up to date.

sudo apt update && apt upgrade -y

When both updates and upgrades are complete, we can go ahead and uninstall old Docker versions.

2. Uninstall old versions of Docker

Old versions of Docker were called docker, docker.io or docker-engine. Uninstall them before installing the new one.

sudo apt-get remove docker docker-engine docker.io containerd runc

If they were not installed then you will see an output like this:

# output
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'docker-engine' is not installed, so not removed
Package 'containerd' is not installed, so not removed
Package 'runc' is not installed, so not removed
Package 'docker' is not installed, so not removed
Package 'docker.io' is not installed, so not removed
The following packages were automatically installed and are no longer required:
  docker-ce-rootless-extras docker-scan-plugin libslirp0 pigz slirp4netns
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

3. Installing Docker on Ubuntu 22.04

There are three methods we can install Docker,

  • Install using the DEB repository
  • Install from the packages
  • Install using a convenient script

Install using .deb Repository

We are installing docker here for the first time, so we need to set up the Docker repository in our system.

To set up the repository first install required dependencies such as, ca-certificates, curl, GnuPG and lsb-release.

sudo apt install ca-certificates curl gnupg lsb-release

The output will be as follows:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
ca-certificates is already the newest version (20211016).
gnupg is already the newest version (2.2.27-3ubuntu2).
gnupg set to manually installed.
lsb-release is already the newest version (11.1.0ubuntu4).
lsb-release set to manually installed.
curl is already the newest version (7.81.0-1ubuntu1.1).
The following packages were automatically installed and are no longer required:
  docker-ce-rootless-extras docker-scan-plugin libslirp0 pigz slirp4netns
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Then the next step is to install GPG key to sign the docker images being installed.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

The next step is to set up a stable, nightly, or test repository depending on what you want to install.

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Lastly, let’s install the Docker engine. To check the available versions we can use the apt-cache madison docker-ce command.

$ sudo apt-cache madison docker-ce
docker-ce | 5:20.10.15~3-0~ubuntu-jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
 docker-ce | 5:20.10.14~3-0~ubuntu-jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
 docker-ce | 5:20.10.13~3-0~ubuntu-jammy | https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages

Install Docker-Engine

Before we can install the Docker engine let’s update our repositories one more time.

$ sudo apt update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin

4. Enable Docker

We need to enable docker-ce to start on reboot, in order to avoid starting every time you boot your machine.

sudo systemctl enable docker

5. Start Docker service

You are supposed to start the docker service to run containerd environment. To start, use the following command.

sudo systemctl start docker

Lastly, we can check the status of docker to see if it is running.

6. Check the status of Docker

Check if Docker is running with the following command on your terminal.

$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset>
     Active: active (running) since Mon 2022-05-09 09:45:15 EAT; 8min ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 9636 (dockerd)
      Tasks: 10
     Memory: 30.5M
        CPU: 477ms
     CGroup: /system.slice/docker.service
             └─9636 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/cont>

May 09 09:45:14 zx-pc dockerd[9636]: time="2022-05-09T09:45:14.783146457+03:00">
May 09 09:45:14 zx-pc dockerd[9636]: time="2022-05-09T09:45:14.783171530+03:00">

If you got status active, then your docker service is running as expected, if not probably you haven’t started the service.

7. Test Docker

Let’s test our docker to see if it is running. Test using hello-world container. This will pull hello-world image from docker hub

$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:10d7d58d5ebd2a652f4d93fdd86da8f265f5318c6a73cc5b6a9798ff6d2b2e67
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

We can try to install ubuntu like this docker run -it ubuntu bash

$ sudo docker run -it ubuntu bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
125a6e411906: Pull complete 
Digest: sha256:26c68657ccce2cb0a31b330cb0be2b5e108d467f641c62e13ab40cbec258c68d
Status: Downloaded newer image for ubuntu:latest
root@c867239ffe6a:/# 

You now have running ubuntu inside a docker container.

Install Docker using a convenient script

Using this method is not recommended for the production environment. Use it only when doing some tests.

To download the script run the following:

curl -fsSL https://get.docker.com -o get-docker.sh

Then execute the script with this command:

sudo sh get-docker.sh

Install Docker from the Package

To install Docker from the package, go to docker distros page and chose Ubuntu distribution, then choose if you want stable, nightly or test version.

Download the package

wget https://download.docker.com/linux/ubuntu/dists/jammy/stable/Contents-amd64

Run the installation using the following command:

sudo dpkg -i /path/to/package.deb

Uninstalling Docker

Whenever you want to uninstall docker from your machine, use the following command to completely remove the installation.

sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-compose-plugin

Then you need to delete all the images, volumes, and containers with these commands

$ sudo rm -rf /var/lib/docker
$ sudo rm -rf /var/lib/containerd

Conclusion

From here you can see our Docker is running as expected, Learn other docker commands to be well conversant with docker. Docker Documentation has a tone of information.

How to install Docker Compose V2 on Ubuntu 22.04

Docker is a set of platform-as-a-service product that uses OS-level virtualization to deliver software in packages called containers. Containers are usually isolated from one another and bundled with their own software libraries and configuration files, they can communicate with each other through well-defined channels.

Docker makes it possible to get more apps running on the same old servers and also makes it easy to package and ship programs.

Docker-compose is a tool for defining and running multi-container Docker application. It uses YAML files to configure its application services.

Steps on using compose

  • First define your app’s environment with Dockerfile so that it can be reproduced anywhere.
  • Define the services that make up your app in docker-compose.yaml so they can be run together in an isolated environment.
  • Lastly run docker compose up to start and run your entire app.

Prerequisites

  • Have Docker up and running on your Ubuntu 22.04.
  • Make sure you are running on sudo privileges
  • Ubuntu 22.04 server up and running.

Installing Docker compose v2 on Ubuntu 22.04

The difference between docker compose v1 and v2 is that v1 uses hyphen when running commands. On v2 they remove that hyphen between different commands. For example is: for docker v1 docker-compose up but for v2 we use docker compose up

Update system repositories

Begin by updating and upgrading your system repositories in order to make them up to date.

sudo apt update && apt upgrade -y

Install Docker on Ubuntu 22.04

As a prerequisite, we need to have docker installed on our system before we can continue with the docker-compose installation.

Let’s first begin by installing some prerequisites on our system

sudo apt install apt-transport-https ca-certificates curl software-properties-common

Then we need to add a GPG key into our system repository to validate the docker images.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Next is to add the Docker repository to apt so that docker will get to know where to access it resources files.

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Lastly, let’s do a system update once more to refresh our repositories.

sudo apt update

we can now install docker in Ubuntu 22.04 with this command sudo apt install docker-ce but first, we can check if docker is available in our repositories with this command.

$ apt-cache policy docker-ce
docker-ce:
  Installed: (none)
  Candidate: 5:20.10.15~3-0~ubuntu-jammy
  Version table:
     5:20.10.15~3-0~ubuntu-jammy 500
        500 https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
     5:20.10.14~3-0~ubuntu-jammy 500
        500 https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
     5:20.10.13~3-0~ubuntu-jammy 500
        500 https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages

Notice we are installing docker-ce, this is the community version not the enterprise version.

Install docker

To install docker run this command on your terminal.

sudo apt install docker-ce -y

You will see this output.

The following additional packages will be installed:
  containerd.io docker-ce-cli docker-ce-rootless-extras docker-scan-plugin
  libslirp0 pigz slirp4netns
Suggested packages:
  aufs-tools cgroupfs-mount | cgroup-lite
The following NEW packages will be installed:
  containerd.io docker-ce docker-ce-cli docker-ce-rootless-extras
  docker-scan-plugin libslirp0 pigz slirp4netns
0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 101 MB of archives.
After this operation, 421 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Verify that the docker engine is running with the hello-world command.

sudo docker-run hello world

Installing Docker compose on Ubuntu 22.04

Now it’s time we install docker-compose on our system.

First, let’s create a directory in the home folder

mkdir -p ~/.docker/cli-plugins/

Next is to download the latest stable release from docker releases page.

curl -SL https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose

Make sure you give the right permission so that you will be in a position to execute docker-compose. Use this command to give requisite permission.

chmod +x ~/.docker/cli-plugins/docker-compose

You can check the version of docker compose installed.

$ docker compose version
Docker Compose version v2.5.0

Create docker-compose.yml file

mkdir ~/demo
cd ~/demo
nano docker-compose.yml

Paste the following into docker-compose.yml file

version: '3.9'

services:
  redis:
    image: redis:6.2-alpine
    ports:
      - 6379:6379
    command: redis-server --save 60 1 --requirepass MDNcVb924a --loglevel warning

To start the container engine we use docker compose up -d

$ docker compose up -d 
[+] Running 7/7
 ⠿ redis Pulled                                                                12.7s
   ⠿ df9b9388f04a Pull complete                                                 3.0s
   ⠿ 192e03523482 Pull complete                                                 3.1s
   ⠿ 7151bccd2756 Pull complete                                                 3.3s
   ⠿ 16ca30b6b4df Pull complete                                                 6.3s
   ⠿ b8157a69ff12 Pull complete                                                 6.3s
   ⠿ 02fb42b94dab Pull complete                                                 6.4s
[+] Running 2/2
 ⠿ Network demo_default    Created                                              0.1s
 ⠿ Container demo-redis-1  Started 

Verify the container processes using:

$ docker compose ps
NAME                COMMAND                  SERVICE             STATUS              PORTS
demo-redis-1        "docker-entrypoint.s…"   redis               running             0.0.0.0:6379->6379/tcp, :::6379->6379/tcp

Let’s login to our Redis container using the following command.

/data # redis-cli
127.0.0.1:6379> keys pattern
(error) NOAUTH Authentication required.
127.0.0.1:6379> keys *
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth MDNcVb924a
OK
127.0.0.1:6379> keys pattern
(empty array)
127.0.0.1:6379> 

Uninstall Docker Engine

When you are done experimenting with the docker engine you can install using the following command.

sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-compose-plugin

To delete images, containers, volumes, or customized config files you need to delete them manually by using the following commands.

$ sudo rm -rf /var/lib/docker
$ sudo rm -rf /var/lib/containerd

Conclusion

We have successfully installed Docker compose v2 on Ubuntu 22.04.

How to set up a Python Django Application using Django 4.0

Django is a backend development language, it is a language for perfectionists. This is called so because it gives you many components out of blue. Whenever you want to develop an application, Django is the go-to language.

To start using Django, you need to be well conversant with Python language first. Begin by knowing all Python-related stuff such as variables, how to do looping in python, tuples, and dictionaries because this is what you encounter every time while working with Django.

In this tutorial, I will take you through setting the Python Django project. The easiest way to do what I usually use is using Pycharm text editor.

Steps to follow:

Step 1: Open Pycharm text editor.

On the upper left corner click on file->New project->Name of the project->create

file->New project->Name of the project->create

Here Pycharm automatically creates a project for you.

Alternatively, you can create a virtual environment on your terminal using this process: How to install Python Django on Ubuntu 20.04

Step 2: Creating a Project

Creating a project is the easiest part, first install Django using the following command on the build-in terminal on Pycharm.

$pip install django~=4.0
Collecting django
  Using cached Django-4.0.4-py3-none-any.whl (8.0 MB)
Collecting asgiref<4,>=3.4.1
  Using cached asgiref-3.5.1-py3-none-any.whl (22 kB)
Collecting sqlparse>=0.2.2
  Using cached sqlparse-0.4.2-py3-none-any.whl (42 kB)
Installing collected packages: sqlparse, asgiref, django
Successfully installed asgiref-3.5.1 django-4.0.4 sqlparse-0.4.2

You can check the version of Django using this command.

$ python -m django --version
4.0.4

Next is to start your project.

On your command line use the following to start a new project.

django-admin startproject myproject .

Make use of the period at the end, it is necessary because it’s instructing that the project be created in the current directory.

If you do an ls inside the project directory, you should see the following:

$ls
manage.py  myproject

Inside my project, this should be what you can find inside

asgi.py  __init__.py  settings.py  urls.py  wsgi.py

Step 3: Start development server

When you are satisfied with your setup, start the development server while inside the root of the Django project. The root of the Django project is the directory where manage.py is located. in our case its inside myproject folder.

nextgentips-Root of Django project

Use the following command to run the development server.

$ python manage.py runserver

This will start the development server and you will the following from your terminal.


System check identified no issues (0 silenced).

You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
May 03, 2022 - 18:39:21
Django version 4.0.4, using settings 'myproject.settings'
Starting development server at http://127.0.0.1:8000/

Don’t worry about the 18 unapplied migrations, we will fix those in a moment. Look the development server will run at port 8000 on our localhost. Copy that URL and paste it into your browser. This is what you will get.

Nextgentips-development server

Step 4: Creating an App

Whenever you are creating a project, there are modules that contain the element you want to implement. Let’s say you want to create an e-commerce website, you will want to divide your project into tiny modules called apps. For example, you will create a products app, cart app, customer app, etc. This will make your project more convenient and elegant.

So to create an app use the following command inside the root of your Django project.

python manage.py startapp product

Product is the name of our app in this example.

Inside the created project folder, this is what you will see.

admin.py  apps.py  __init__.py  migrations  models.py  tests.py  views.py

This will be the directory structure

nextgentips-directory structure

Step 5: Creating your first view

As you can see from the screenshot above, we have views.py. Click on it, this is where you will write your logic. Inside your view insert the following code.

from django.shortcuts import render

from django.http import HttpResponse


def home_view(request):
    return HttpResponse('

Hello world

')

I want you to create another file called URLs inside your app, then you will need to insert the following in that urls.py

product/urls.py

from django.urls import path


from .views import home_view

urlpatterns = [
    path('', home_view, name='home')
]

Then on the myproject/urls.py insert the following:

from django.contrib import admin
from django.urls import path, include 

urlpatterns = [
    path('', include('product.urls')),
    path('admin/', admin.site.urls),
]

On the settings.py you need to register your app. Go to settings.py->installed_apps->AddYour app name in our case its product.

Go to settings.py->installed_apps->'product.apps.ProductConfig'

Refresh your browser and you will see Hello world printed on your screen.

Hello world

In the next lesson, we will see how to create a project using templates and how to do our first database migration.