How to Install Docker on Ubuntu 18.04 & 16.04 LTS
Prerequisites
-
A 64-bit version of Ubuntu 18.04 or 16.04.
-
A user account with
sudo
privileges. -
A stable internet connection.
Step 1: Uninstall Old Versions (if any)
Before installing Docker, remove any older versions to avoid conflicts:
Step 2: Set Up Docker’s Official Repository
-
Update the package index:
-
Install required packages:
-
Add Docker’s official GPG key:
-
Set up the stable repository:
For Ubuntu 18.04:
For Ubuntu 16.04:
Step 3: Install Docker Engine
-
Update the package index again:
-
Install Docker CE (Community Edition):
Step 4: Start and Enable Docker
-
Start Docker:
-
Enable Docker to start on boot:
Step 5: Verify Docker Installation
Run the following command to check if Docker is installed correctly:
If Docker is installed correctly, you'll see a message saying:
Step 6: Manage Docker as a Non-root User (Optional)
To run Docker commands without sudo
, add your user to the Docker group:
Note: Log out and log back in for the group changes to take effect.
Step 7: Test Docker Without sudo
After logging back in, test Docker without using sudo
:
Step 8: Update Docker (Optional)
To keep Docker up to date, periodically run:
Step 9: Uninstall Docker (if needed)
To remove Docker from your system:
For more detailed information, you can refer to the official Docker documentation:
If you need assistance with Docker Compose or Docker Desktop, feel free to ask!