# To install docker in ubuntu, run the following in your terminal:sudoapt-get update
sudoaptinstall-y 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 -y"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"sudoapt-get update
sudoaptinstall docker-ce
## This instruction from the official website will install the latest release of docker.# Uninstall old versions# Older versions of Docker were called docker, docker.io, or docker-engine. If these are installed, uninstall them:sudoapt remove docker docker-engine docker.io containerd runc
# Install using the repository sudoapt update
sudoapt-getinstall ca-certificates curl gnupg lsb-release
# Add Docker’s official GPG key:sudomkdir-p /etc/apt/keyrings
curl-fsSL https://download.docker.com/linux/ubuntu/gpg |sudo gpg --dearmor-o /etc/apt/keyrings/docker.gpg
# Set up the repository echo"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu
$(lsb_release -cs) stable"|sudotee /etc/apt/sources.list.d/docker.list > /dev/null
# Install Docker Enginesudoapt-get update
sudoapt-getinstall docker-ce docker-ce-cli containerd.io docker-compose-plugin
# Receiving a GPG error when running apt-get update?# Your default umask may not be set correctly, causing the public key file for the repo to not be detected. Run the following command and then try to update your repo again: sudo chmod a+r /etc/apt/keyrings/docker.gpg.# Verify that Docker Engine is installed correctly by running the hello-world imagesudodocker run hello-world
#This command downloads a test image and runs it in a container. When the container runs, it prints a message and exits
sudoaptinstall docker.io # install dockersudo systemctl start docker# start servicesudo systemctl stop docker# stop servicesudo systemctl status docker# To check status of dockerdocker--version# to check the version of docker
curl-fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
sudousermod-aGdocker youruser (OPTIONAL:"don't use with Redhat, Fedora, Centos if concerned about security" Add user to docker group to run commands without using sudo)