Docker on Ubuntu: Complete Installation Guide
To install and use Docker containers on Ubuntu, you can follow these steps:
- Update Ubuntu package index.
sudo apt update
- Install the necessary software packages to enable Ubuntu to use HTTPS.
sudo apt install apt-transport-https ca-certificates curl software-properties-common
- Add the official GPG key for Docker.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- Add the stable version of Docker software package repository.
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- Update the package index.
sudo apt update
- Install the Docker engine.
sudo apt install docker-ce
- Start the Docker service and set it to launch automatically at startup.
sudo systemctl start docker
sudo systemctl enable docker
- Check if Docker has been successfully installed.
docker --version
You can now manage containers using Docker commands. For example, you can pull an Ubuntu image and run a container with the following command:
docker pull ubuntu
docker run -it ubuntu
This will open an interactive session within the Ubuntu container where you can execute commands. To exit the container, you can use Ctrl + D or input the exit command.
I hope this guide can assist you in installing and using Docker containers on Ubuntu.