Remove Docker on ubuntu 18 - docker

I had installed docker in ubuntu 18 and now wants to remove everything for a clean install. Had used : sudo apt-get install docker.io
This stackoverflow thread (though not meant for my exact installation) has a part-solution: docker remove answer
The only problem is that it doesn't mention how to remove other remaining docker files after running find / -name '*docker*' . There are so many in my system! screenshot_1 after "find / -name docker " >> screenshot_2 after "find / -name docker "
Additionally, I am looking for simple, hassle-free steps to install opensourcePOS on ubuntu 18 (Local deploy) git osPOS . The ones on git and osPOS website are for advanced users I guess - they leave a lot of details. Any links?

Try:
sudo apt-get purge -y docker.io
sudo apt-get autoremove -y --purge docker.io
sudo apt-get autoclean
sudo rm -rf /var/lib/docker
sudo rm -rf /etc/docker
sudo rm /etc/apparmor.d/docker
sudo apt-get purge runc containerd docker.io

You can easily remove docker on linux by nautilus:
Open Nautilus.
Go to Other Locations.
Go to Computer.
Search Docker.
Select All the Files docker and delete it.

This is the command docker suggests to use if you want to remove docker. I used it in ubuntu 18
https://docs.docker.com/engine/install/ubuntu/#uninstall-docker-engine
sudo apt-get remove docker docker-engine docker.io containerd runc

Related

Kubernetes' container creation with flannel gets stuck in "ContainerCreating"-state

Context
I installed Docker following this instruction on my Ubuntu 18.04 LTS (Server) and later on Kubernetes followed via kubeadm. After initializing (kubeadm init --pod-network-cidr=10.10.10.10/24) and joining a second node (I got a two node cluster for the start) I cannot get my coredns as well as the later applied Web UI (Dashboard) to actually go into status Running.
As pod network I tried both, Flannel (kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/2140ac876ef134e0ed5af15c65e414cf26827915/Documentation/kube-flannel.yml) and Weave Net - Nothing changed. It still shows status ContainerCreating, even after hours of waiting:
Question
Why doesn't the container creation work as expected and what might be the root cause for this? And most importantly: How do I solve this?
Edit
Summing up my answer below, here are the reasons why:
Docker used cgroups instead of systemd
I did not configure iptables correctly
I used a wrong kubeadm init since flannels standard-yaml requires --pod-network-cidr to be 10.244.0.0/16
Since answering this questions took me a lot of time, I wanted to share what got me out of this. There might be some more code than necessary, but I also want this to be in one place if I or someone else has to redo all steps.
First it all started with Docker...
I figured out that it presumably all started with the way I installed Docker. Following the linked online-instructions I used sudo apt-get install docker.io in order to install Docker and used it with cgroups by doing sudo usermod -aG docker $USER.
Well, taking a look at the official instructions from Kubernetes this was a mistake: systemd is the recommended way to go!
So I completly purged all I ever did with docker by following these great instructions from
Mayur Bhandare:
sudo apt-get purge -y docker-engine docker docker.io docker-ce
sudo apt-get autoremove -y --purge docker-engine docker docker.io docker-ce
sudo rm -rf /var/lib/docker /etc/docker
sudo rm /etc/apparmor.d/docker
sudo groupdel docker
sudo rm -rf /var/run/docker.sock
# Reboot to be sure
Afterwards I installed reinstalled the official way (keep in mind that this might change in the future):
# Install Docker CE
## Set up the repository:
### Install packages to allow apt to use a repository over HTTPS
apt-get update && apt-get install -y \
apt-transport-https ca-certificates curl software-properties-common gnupg2
### Add Docker’s official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
### Add Docker apt repository.
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
## Install Docker CE.
apt-get update && apt-get install -y \
containerd.io=1.2.10-3 \
docker-ce=5:19.03.4~3-0~ubuntu-$(lsb_release -cs) \
docker-ce-cli=5:19.03.4~3-0~ubuntu-$(lsb_release -cs)
# Setup daemon.
cat > /etc/docker/daemon.json <<EOF
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
mkdir -p /etc/systemd/system/docker.service.d
# Restart docker.
systemctl daemon-reload
systemctl restart docker
Note that this explicitly uses systemd!
... and then it went on with Flannel...
Above I wrote my sudo kubeadm init was done with --pod-network-cidr=10.10.10.10/24 since the latter was the IP of my master.
Well, as pointed out here not using the official recommended --pod-network-cidr=10.244.0.0/16 results in an error for example using kubectl proxy or the container-creation when using the provided kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/2140ac876ef134e0ed5af15c65e414cf26827915/Documentation/kube-flannel.yml.
This is due to the fact that 10.244.0.0/16 is hard-linked in the .yaml and, hence, mandatory - Or you just change it in the .yaml.
In order to get rid of the false configuration I did a full reset.
This can be achieved using sudo kubeadm reset and by deleting the config with sudo rm -r ~/.kube/config.
Anyhow, since I screwed it so much, I did a full reset by uninstalling and reinstalling kubeadm and making sure it did use iptables this time (which I also forgot to do before...).
Here is a nice link how to fully uninstall all kubeadm-parts.
kubeadm reset
sudo apt-get purge kubeadm kubectl kubelet kubernetes-cni kube*
sudo apt-get autoremove
sudo rm -rf ~/.kube
For the sake of completeness, here is the reinstall as well:
# ensure legacy binaries are installed
sudo apt-get install -y iptables arptables ebtables
# switch to legacy versions
sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
sudo update-alternatives --set arptables /usr/sbin/arptables-legacy
sudo update-alternatives --set ebtables /usr/sbin/ebtables-legacy
# Install Kubernetes with kubeadm
sudo apt-get update && sudo apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
#reboot
... and finally it worked!
After the clean reinstallation I did the following:
# Initialize with correct cidr
sudo kubeadm init --pod-network-cidr=10.244.0.0/16
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/2140ac876ef134e0ed5af15c65e414cf26827915/Documentation/kube-flannel.yml
And then be astouned by the result:
kubectl get pods --all-namespaces
On a site note: This also resolved the /run/flannel/subnet.env: no such file or directory-error I encountered prior to these steps when describing the uncreated coredns.
So I had the same issue as stated above. For me, this was the perfect solution to fix this, but also other pods were stuck on either pending or ContainerCreating.
In addition as the fix above, my flannel encountered an unnoticed error, so I needed to rerun the flannel create.
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

How to install Docker in Ubuntu offline

I need to install Docker in an Ubuntu 18 machine which do not have any internet access. There are plethora of instruction material exist on this this subject but all they require Ubuntu machine to be online.
Any help on offline installation of Docker will be highly helpful.
Thanks,
On any machine with internet access, do the following:
Go to https://download.docker.com/linux/ubuntu/dists
Choose your Ubuntu distribution (For 18.0.4 it would be beaver/)
Navigate to pool/stable/<processor architecture>
Download the most recent version of each package
After transferring the .deb files to your offline Ubuntu machine/VM:
In a terminal, navigate to the folder which contains your .deb files
Execute dpkg -i <package1> <package2> <package3> in order to install the downloaded packages
Verify that the service is running by switching to /opt/ and executing systemctl status docker.service
After this you should be able to configure your docker installation and import packages via the docker load command
Run these commands:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu `lsb_release -cs` test"
sudo apt update
sudo apt install docker-ce

Error showing while trying to install Docker CE on Linux Ubuntu 18.04 Bionic?

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
docker-ce
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/33,8 MB of archives.
After this operation, 181 MB of additional disk space will be used.
(
Reading database ... 129600 files and directories currently installed.)
Preparing to unpack .../docker-ce_18.03.1~ce-0~ubuntu_amd64.deb ...
Unpacking docker-ce (18.03.1~ce-0~ubuntu) ...
dpkg: error processing archive /var/cache/apt/archives/docker-ce_18.03.1~ce-0~ubuntu_amd64.deb (--unpack):
trying to overwrite '/usr/bin/docker-containerd', which is also in package docker-containerd 0.2.3+git+docker1.13.1~ds1-1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cache/apt/archives/docker-ce_18.03.1~ce-0~ubuntu_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
I got this error when trying to install the latest Docker (v20.10.17) on Ubuntu Focal 20.04 (LTS) following the official documentation. I tried installing older versions and got the same error. When running sudo dockerd --debug it showed the real error:
failed to start daemon: Devices cgroup isn't mounted
Cgroupfs (Control Groups) are a kernel mechanism for tracking and imposing limits on resource usage on groups of tasks. So the solution is to mount it. Note that you need to stop the container daemon before mounting the cgroup and then start it again after that.
Stop daemon
sudo systemctl stop containerd
Unmount (just in case) and then mount the cgroup
sudo cgroupfs-umount
sudo cgroupfs-mount
Start the daemon again
sudo systemctl start containerd
sudo systemctl start docker.service
sudo systemctl start docker.socket
If there are errors still, re-install everything
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
Test that Docker works
sudo docker run hello-world
I don't see 18.04 listed on the supported list so you may be encountering compatibility issues that the developers have not had time to resolve. To work around your immediate issue, I would uninstall "docker-containerd" and any other dependent packages since that appears to be based on a very old version of docker (1.13).
apt remove docker-containerd
Step 01 - Uninstall old version of Docker
$ sudo apt-get remove docker docker-engine docker.io containerd runc
$ sudo rm -rf /var/lib/docker
$ sudo apt-get autoclean
$ sudo apt-get update
Step 02 - Install Docker-ce:
Install a few prerequisite packages which let APT use packages over HTTPS:
$ sudo apt install apt-transport-https ca-certificates curl software-properties-common
Add the GPG key for the official Docker repository to system:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Add the Docker repository to APT source:
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
Update the package database
$ sudo apt update
Make sure you are about to install from the Docker repo instead of the default Ubuntu repo
$ apt-cache policy docker-ce
Finally, install Docker:
$ sudo apt install docker-ce
Verify docker is running
$ sudo systemctl status docker

Docker is not able to be installed on ubuntu 14.04

I am doing the steps as shown below to install docker:
sudo apt-get update
sudo apt-get install docker
The to start docker I am using sudo service docker start.But then it says docker : unrecognized service. I have followed every steps , is there any step missing in this process
Please remove all old packages by using this command.
sudo apt-get remove docker*
I think you have to install repo by using following command.
if you use 64bit Ubuntu version
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
and after that
sudo apt-get update
sudo apt-get -y install docker.io
And confirm version by using
dom#dom-pc:~/web$ docker version
Client:
Version: 1.12.6
API version: 1.24
Go version: go1.7.4
Git commit: XXXXXXX
Built: Tue Mar 14 09:47:15 2017
OS/Arch: linux/amd64
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
and if you wanted to upgrade to a later version
ls /usr/bin | grep docker remove these files
docker
docker-containerd
docker-containerd-ctr
docker-containerd-shim
dockerd
docker-init
docker-proxy
docker-runc
wget
https://download.docker.com/linux/static/stable/x86_64/docker-17.06.1-ce.tgz
(or whatever stable version you wanted)
tar xfvz docker-17.06.1-ce.tgz
cp docker/* /usr/bin/
docker -v and you're done.
Follow these steps
$ sudo apt-get remove docker docker-engine docker.io
$ sudo apt-get update
$ sudo apt-get install docker-ce

How to repair docker or reinstall it?

I have done this command and now docker don't work...
How can I repair (or reintall) docker properly?
sudo rm -rf /var/lib/docker/aufs
I have try to do
apt-get install --reinstall docker
but it didn't work
this is my error message:
docker: Error response from daemon: open /var/lib/docker/aufs/layers/c14f6c4750a2a3fcfa33e6f33041bf4fce087d314fb413ee3662e6e7035fea75: no such file or directory.
Try this on ubuntu with docker-ce
sudo apt-get install --reinstall docker-ce
That was seen only with older versions of docker (issue 22343), but also more recently with 16.04.1 LTS, Docker version 1.12.1, build
It depends on which docker you are using, and on which host OS.
If you are on Ubuntu for instance, try removing docker completely (if you don't have any local work that you would want to keep)
sudo apt-get purge docker-engine
sudo apt-get autoremove --purge docker-engine
rm -rf /var/lib/docker # This deletes all images, containers, and volumes
Then install the latest docker 13.1 and see if the issue persists.
Again, this is only if you are ready to start again from a clean state, reinstalling Docker entirely.
Do not execute rm -rf /var/lib/docker without considering the consequences, or in a production environment(!).
rakeshz's answer using an apt-get install --reinstall is a safer first step.

Resources