Tuesday, 22 March 2022

Install Docker on Ubuntu 20.04


sudo apt update

sudo apt-get install \

    ca-certificates \

    curl \

    gnupg \

    lsb-release


sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg


sudo echo \

>  "deb [arch=$(dpkg --print-architecture) 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


sudo docker --version

Docker version 20.10.13, build a224086


sudo systemctl status docker

● docker.service - Docker Application Container Engine

     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)

     Active: active (running) since Tue 2022-03-22 16:21:57 PDT; 2min 37s ago

...


#check Docker is working correctly

sudo docker run hello-world

#list complete list of available subcommands

docker

#for more information on a command

docker COMMAND --help


#view system-wide information

sudo docker info

#crawl Docker Hub and return a listing of all images 

sudo docker search ubuntu

#see the images that have been downloaded

sudo docker images


#view the active containers

sudo docker ps

#view all containers — active and inactive

sudo docker ps -a

#view the latest container

sudo docker ps -l


#start container with the ID/NAME

sudo docker start container_ID/container_NAME

#stop container with the ID/NAME

sudo docker stop container_ID/container_NAME

#delete container

sudo docker rm container_ID/container_NAME


No comments:

Post a Comment