you can do these steps with ssh from another computer.
I did it via ssh from another computer because the server that has Ubuntu Server does not have a screen, mouse, or keyboard.
the apt package manager is used.
update the system
sudo apt update
sudo apt full-upgrade -y
Install the packages required for Docker installation:
sudo apt install -y ca-certificates curl gnupg lsb-release
The packages to be installed are:
- ca-certificates: A set of certificate authority (CA) certificates for verifying the authenticity of websites and other services.
- curl: A command line tool for transferring data over protocols such as HTTP, HTTPS, FTP, etc.
- gnupg: An implementation of GNU Privacy Guard (GPG) public key cryptography for encrypting and decrypting messages and files.
- lsb-release: A package that provides information about the operating system version and other data related to Linux Standard Base (LSB) compatibility.
The -y option is used to automatically answer “yes” to any questions asked during installation. This means that the installation will be performed without any user intervention.
add Docker GPG key to verify authenticity of packages:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Add the Docker repository to the APT sources list:
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
Install Docker using the following command:
sudo apt update
sudo apt install -y docker.io
On Ubuntu Server, the docker.io package is used instead of docker-ce
Start and enable the Docker service to run automatically at system boot:
sudo systemctl start docker
sudo systemctl enable docker
restart the computer
Verify that Docker is installed and running correctly:
sudo docker run hello-world