Install Docker on Ubuntu
To install Docker on Ubuntu, you can follow these steps:
Step 1: Update Package Index
First, update the package index to ensure you install the latest versions of Docker and its dependencies:
sudo apt update
Step 2: Install Dependencies
Install the packages necessary to allow apt to use a repository over HTTPS:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Step 3: Add Docker's Official GPG Key
Add Docker's official GPG key to your system:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Step 4: Add Docker Repository
Add the Docker repository to your APT sources:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Step 5: Install Docker Engine
Update the package index again, and install Docker:
sudo apt update
sudo apt install docker-ce
Step 6: Verify Docker Installation
Check that Docker Engine is installed correctly by running the hello-world
container:
sudo docker run hello-world
This command downloads a test image and runs it in a container. If Docker is set up correctly, you should see a message confirming that Docker is working.
Step 7: Manage Docker as a Non-Root User (Optional)
If you want to run Docker commands without using sudo
, add your user to the docker
group:
sudo usermod -aG docker ${USER}
Log out and back in, or run newgrp docker
, to activate the changes.
Step 8: Start and Automate Docker
Start Docker and enable it to start on boot:
sudo systemctl start docker
sudo systemctl enable docker
Step 9: Verify Docker Version (Optional)
To verify the installed Docker version, you can use:
docker --version
That's it! Docker should now be installed and ready to use on your Ubuntu system.
No Comments