Install Docker
Remove older version of docker if any:
Ubuntu:
sudo apt-get remove docker docker-engine docker.io containerd runc
CentOS:
sudo yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine
Update Packages:
Ubuntu:
sudo apt-get update
CentOS:
sudo yum install -y yum-utils
Install Docker:
Ubuntu:
sudo apt-get install docker.io
CentOS:
sudo yum install docker.io
Done. You have successfully installed Docker in your system!
Install Docker Compose
Ubuntu
sudo apt install docker-compose
CentOs:
sudo yum install docker-compose
Check versions
Docker
docker --version
docker-compose
docker-compose --version
Check the Status of the Docker
To check the status of the docker run
systemctl
or withservice
:systemctl status docker
service docker stauts
Active with green color shows that Docker is running.
Run Docker
Let's test Docker whether it runs or not.
First, start the docker with
systemctl
(may need for CentOS users):sudo systemctl start docker
Run to test hello-world image:
sudo docker run hello-world
This command downloads a test image and runs it in a container. When the container runs, it prints a confirmation message and exits.
Uninstall Docker
Stop Docker:
sudo systemctl stop docker
Delete the Docker packages:
Ubuntu:
sudo apt-get purge -y docker-engine docker docker.io docker-ce docker-ce-cli docker-compose-plugin
sudo apt-get autoremove -y --purge docker-engine docker docker.io docker-ce docker-compose-plugin
CentOS:
sudo yum remove docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine \
Remove some of the docker files:
Ubuntu:
sudo rm -rf /var/lib/docker /etc/docker
sudo rm /etc/apparmor.d/docker
sudo groupdel docker
sudo rm -rf /var/run/docker.sock
CentOS:
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
sudo rm -rf /etc/docker
Reboot the system:
sudo reboot now
Done. You have completely removed the Docker from your system.
If you have further queries just comment on this post ๐