Preparing for Installation
Before we dive into the installation process, let's make sure your Ubuntu machine meets the necessary requirements. Docker requires a 64-bit version of Ubuntu and a kernel version of 3.10 or higher. To check your Ubuntu version, open a terminal and run the following command:
If you have a 64-bit version and a compatible kernel, you're ready to proceed with the installation.
Installing Docker on Ubuntu
To install Docker on Ubuntu, we'll use the official Docker repository. Follow these steps:
- Update the apt package index:
sudo apt update
- Install the necessary packages to allow apt to use a repository over HTTPS:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
- Add the Docker GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
- Add the Docker repository:
echo "deb [arch=amd64 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
- Update the apt package index again:
sudo apt update
- Install Docker:
sudo apt install docker-ce docker-ce-cli containerd.io
- Verify that Docker is installed correctly:
sudo docker run hello-world
Congratulations! Docker is now installed on your Ubuntu machine.
Running Docker Commands
Now that Docker is installed, let's explore some useful Docker commands.
To check the version of Docker installed, run:
To list all the Docker images on your system, use the following command:
To run a Docker container, you can use the
docker run command followed by the image name. For example:
docker run ubuntu
To stop a running container, use:
docker stop <container_id>
Now that you have Docker up and running on your Ubuntu machine, you can start exploring its vast capabilities.
If you're facing issues with the Docker installation process or encountering errors, refer to our article on bash: docker: command not found for troubleshooting tips.
To learn more about container orchestration and comparison between Docker and Kubernetes, check out our articles on Advantages and Disadvantages of Container Orchestration and Docker vs Kubernetes: Which Container Orchestration Tool Should You Choose?.
Remember, Docker is a powerful tool that can revolutionize your application deployment process. Embrace the world of containerization and unlock endless possibilities with Docker on Ubuntu!