docker service is not enabled - Kubernetes - linux

I'm trying to install Kubernetes on an EC2 instance running Ubuntu 20.04.
I ran the following commands to install Kubeadm and Docker.
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
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
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo snap install docker
sudo kubeadm init
When I try to run Kubeadm init in order to initialize my Kubernetes control node, I get the following error:
[init] Using Kubernetes version: v1.23.4
[preflight] Running pre-flight checks
[WARNING Service-Docker]: docker service is not enabled, please run 'systemctl enable docker.service'
error execution phase preflight: [preflight] Some fatal errors occurred:
[ERROR Service-Docker]: docker service is not active, please run 'systemctl start docker.service'
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher
I subsequently checked to see if Docker was properly installed and pulled an Ubuntu 20.04 docker image and successfully ran it in interactive mode. So, I'm sure that Docker is running.
Does anyone have an idea as to what might be the issue?
My Kubeadm version is:
kubeadm version: &version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.4", GitCommit:"e6c093d87ea4cbb530a7b2ae91e54c0842d8308a", GitTreeState:"clean", BuildDate:"2022-02-16T12:36:57Z", GoVersion:"go1.17.7", Compiler:"gc", Platform:"linux/amd64"}
My Docker version is:
Docker version 20.10.7, build 20.10.7-0ubuntu5~20.04.2

The issue was that I installed docker using snap.
This creates a service name that seems to cause issues with Kubernetes.
Install docker for Ubuntu 20.04 using directions on the official Docker website with apt-get. This seems to work.

Related

how to resolve docker throwing Error on Centos 7 VM

I have installed docker on my centos 7 VM running on Azure. I used below commands to install docker:
sudo yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin
After successfully installing docker, I'm getting below error. Can someone please suggest what could be the problem.
sudo docker --version
runtime: s.allocCount= 37 s.nelems= 73
fatal error: s.allocCount != s.nelems && freeIndex == s.nelems
goroutine 1 [running, locked to thread]:
runtime.throw({0x562d045c5c70?, 0x7fb997110112?})
/usr/local/go/src/runtime/panic.go:992 +0x71 fp=0xc0001def58 sp=0xc0001def28 pc=0x562d032fb1d1
runtime.(*mcache).nextFree(0x7fb997110108, 0x12)
/usr/local/go/src/runtime/malloc.go:884 +0x1e5 fp=0xc0001defa0 sp=0xc0001def58 pc=0x562d032d3085
runtime.mallocgc(0x70, 0x562d04d1cea0, 0x1)
/usr/local/go/src/runtime/malloc.go:1085 +0x4e5 fp=0xc0001df018 sp=0xc0001defa0 pc=0x562d032d35a5
runtime.newobject(0x562d04c463a0?)
/usr/local/go/src/runtime/malloc.go:1259 +0x27 fp=0xc0001df040 sp=0xc0001df018 pc=0x562d032d3ae7
regexp/syntax.(*Regexp).Simplify(0xc00023ccb0)
/usr/local/go/src/regexp/syntax/simplify.go:98 +0x945 fp=0xc0001df150 sp=0xc0001df040 pc=0x562d036194c5
regexp/syntax.(*Regexp).Simplify(0xc00023cd20)
/usr/local/go/src/regexp/syntax/simplify.go:23 +0x4cc fp=0xc0001df260 sp=0xc0001df150 pc=0x562d0361904c
regexp/syntax.(*Regexp).Simplify(0xc00023cb60)
/usr/local/go/src/regexp/syntax/simplify.go:23 +0x4cc fp=0xc0001df370 sp=0xc0001df260 pc=0x562d0361904c
I removed docker completely and installed again. But got the same error.
I tried to reproduce the same issue in my environment and got the below results
I have created the Centos-vm and I tried to install the docker into the Centos
sudo yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin
When I use the above command I got the appropriate results
In the docker module it self there is no packages available so docker it will show successfully installed but it will not run
I have used the below command to install the docker
sudo yum update check-update
curl -fsSL https://get.docker.com/ | sh
Docker installed successfully
Here is my docker version
I am able to start my docker and the docker status is in active
sudo systemctl start docker
sudo systemctl status docker
NOTE: This error will happen with the old versions also please try to install the latest version of the docker

How to install Minikube on Azure Linux VM - ubuntu 18.04

I want to install Minikube on Azure Linux VM - ubuntu 18.04. But couldn't find the appropriate article. So I would like to the appropriate steps, how to install Minikube on Azure Linux VM and work.
Pré-Requisites before create your VM on Azure:
It’s necessary a machine with nested virtualization. The CPU family with suffix _v3 gives this support, ex: Standard D2s v3, Standard D4s v3.
Standard D2s v3 is a good choice to start
I am using: Linux (ubuntu 18.04)
Login to VM using putty:
Installing Docker
$ curl -fsSL https://get.docker.com | sh
Installing VirtualBox
$ sudo apt install virtualbox virtualbox-ext-pack
Installing Minikube
Updating the system:
$ sudo apt update -y
$ sudo apt upgrade -y
To install the latest minikube stable release on x86–64 Linux using binary download:
$ sudo apt install -y curl wget apt-transport-https
$ curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
$ sudo install minikube-linux-amd64 /usr/local/bin/minikube
Installing Kubectl
$ curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
$ sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
$ kubectl version --client
Start Minikube
$ minikube start
Check Status
$ minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
Get Nodes
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
minikube Ready control-plane 64s v1.25.0
Addons
Only a few addons are enabled by default during the installation but you can turn on
$ minikube addons list
---To activate, run:
$ minikube addons enable <addon-name>
Running the First Deployment
$ kubectl create deployment my-nginx --image=nginx
$ kubectl get deployments.apps my-nginx
$ kubectl get pods

How do I install and configure Docker on Ubuntu-like systems (Kubuntu)

i tried using ddev with Linux Kubuntu and did as proceeded as described here:
https://t3terminal.com/typo3-tutorials/install-typo3-docker-ddev/
means:
// Install DDEV
curl -L https://raw.githubusercontent.com/drud/ddev/master/scripts/install_ddev.sh | bash
// Install mkcert
sudo apt install libnss3-tools
mkcert -install
// Check DDEV works well?
ddev
$ ddev config
… Project name (temp-test): test
… Docroot Location (current directory):
Found a php codebase at ~/github/temp-test.
… Project Type [backdrop, drupal6, drupal7, drupal8, drupal9, laravel, magento, magento2, php, shopware6, typo3, wordpress] (php): laravel
… You may now run 'ddev start'.
~/github/temp-test$ ddev start
Could not connect to docker. Please ensure Docker is installed and running.
So i found this tip's here: Docker can't connect to docker daemon :
~/github/temp-test$ sudo service docker stop && sudo service docker start
Warning: Stopping docker.service, but it can still be activated by:
docker.socket
~/github/temp-test$ ddev start
Could not connect to docker. Please ensure Docker is installed and running.
~/github/temp-test$ sudo service docker start
~/github/temp-test$ ddev start
Could not connect to docker. Please ensure Docker is installed and running.
~/github/temp-test$ sudo service docker restart
~/github/temp-test$
it looks as if docker is installed (because it talks to me Warning: Stopping docker.service) but ddev does not find docker. what else can try?
Docker version
~ docker --version
Docker version 20.10.8, build 3967b7d
Operating System
Kubuntu 20.04
KDE Plasma Version: 5.18.5
KDE Frameworks Version: 5.68.0
Qt Version: 5.12.8
You need to install docker on Kubuntu to use it.
Details are in the [ddev docs].(https://ddev.readthedocs.io/en/stable/users/docker_installation/#linux-installation-docker-and-docker-compose)
But the bottom line is:
You're using the Ubuntu setup.
Use the instructions for Ubuntu 20.04 assuming you're using something 20.04+: sudo apt-get update && sudo apt-get install docker.io docker-compose
Make sure to do the post-install, which requires you to add your own user to the "docker" group. sudo usermod -aG docker $USER, details in the linked docker instructions

Can't run the docker

I just install the Docker on Ubuntu18.04 by using:
sudo apt update
sudo apt upgrade
sudo apt install docker.io
sudo service docker start
All of the above commands work normally, but when I check the status of the docker servicesudo service docker status, it shows"Docker is not running". I have tried sudo service docker restart, but it doesn't work.
I think you missed the docker-ce package:
sudo apt-get install docker-ce
for more information check the documentation at: install docker ce

Installing Docker.io on Ubuntu 14.04LTS

I'm running a virtual machine in Windows Azure with the prebuild image for Ubuntu 14.04 LTS.
When I want to install Docker.io like described here:
http://blog.docker.io/2014/04/docker-in-ubuntu-ubuntu-in-docker/
The installation works but when i`m running:
sudo docker.io pull ubuntu
An error will be thrown:
Cannot connect to the Docker daemon. Is docker -d running on this host?
Can anyone help or has the similar problem?
P.S.: Can anyone with a high reputation create a Tag for Ubuntu-14.04?
Evidently the docker daemon is not running. You wanna check /etc/default/docker.conf for proper configuration and issue
sudo service docker.io start
or
sudo service docker start
depending on how they called the service
Adding myself to the docker group:
sudo usermod -a -G docker myuser
and rebooting the machine worked for me. This solution is discussed in: https://github.com/docker/docker/issues/5314
On Ubuntu 14.04, the docker.io package installs Docker 0.9.1.
According to the documentation, to install the current version use these commands:
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
$ sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
$ sudo apt-get update
$ sudo apt-get install lxc-docker
There is also a simple script available to help with this process:
$ curl -s https://get.docker.io/ubuntu/ | sudo sh
Alternatively, check the azure-docker-registry project for an example of how to automate Azure provisioning and Docker container deployment. For instance, this Ansible playbook:
- name: create docker data directory
file: path=/mnt/data/docker state=directory
- name: store docker files in data disk
file: src=/mnt/data/docker dest=/var/lib/docker state=link
- name: add repository key
command: creates=/etc/apt/sources.list.d/docker.list apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
- name: copy repository source file
copy: src=docker.list dest=/etc/apt/sources.list.d/docker.list
- name: install docker package
apt: name=lxc-docker update_cache=yes state=present
Also make sure to symlink the docker.io binary to docker to use the tutorials/documentation without rewriting every command.
ln -s /usr/bin/docker.io /usr/bin/docker
Run docker -d to see if it shows any error messages.
If apparmor is missing install it with sudo apt-get install apparmor
Then sudo service docker start
Hard to say but sometime official docker installation procedure fails on Ubuntu 14.04.
One can simply install docker using below given commands [Quick and Dirty]
sudo apt-get update
sudo apt-get -y install docker.io

Resources