21
Installing Docker and Kubernetes on Ubuntu
Docker and Kubernetes are the heroes of the DevOps world.
Docker is a containerization platform and Kubernetes is a container orchestrator for platforms like Docker.
Docker is a containerization platform and Kubernetes is a container orchestrator for platforms like Docker.
This article will discuss how we can set up Docker and Kubernetes on our Ubuntu machine.
We will be setting up Docker by adding its repository to our package index and then installing the Docker Debian packages via our
apt
package manager.Let's begin.
First, we will refresh our package index, and install some packages which will help us add PGP keys and setting up therepository right through
https
$ sudo apt-get update
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
Run the below command, and it will automatically add Docker PGP keys to our system
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Now that we are done adding keys, it's time to add the repository URL which will help us install and timely update Docker on our system.
$ echo \
"deb [arch=amd64 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
Now finally, it's time to install Docker. But first, we will need to refresh our package index as well.
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
Now that we have installed Docker, let us test it and give it a try.
sudo docker run hello-world
We will go through the process to install Kubernetes through the
apt
package manager and snap
both. You can choose which suits you betterFirst, we will refresh our package index, and install some packages which will help us add PGP keys and setting up the repository right through
https
$ sudo apt-get update
$ sudo apt-get install -y apt-transport-https ca-certificates curl
Run the below command, and it will automatically add Kubernetes PGP keys to our system
$ sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
Now that we are done adding keys, it's time to add repository URL which will help us install and timely update Kubernetes (
kubectl
) on our system.echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
Now finally, its time to install Kubernetes(
kubectl
). But first, we will need to refresh our package index as well.$ sudo apt-get update
$ sudo apt-get install -y kubectl
Installing
kubectl
via snap
is pretty easy and a single command work. You can also pick this alternative to set up Kubernetes. Though I will recommend installing via apt
package manager as it is easily updatable.$ snap install kubectl --classic
21