2 min read

How to Install Docker with One Command on Ubuntu

How to Install Docker with One Command on Ubuntu
Photo by Mohammad Rahmani / Unsplash

Docker is a powerful platform that allows developers to automate the deployment of applications inside lightweight, portable containers. If you're using Ubuntu and want to get Docker up and running quickly, you're in luck! With just a single command, you can have Docker installed and ready to go. Let's dive into the process.

Why Docker?

Before we jump into the installation, let's briefly touch on why Docker is such a popular tool among developers:

  • Portability: Docker containers can run on any system that supports Docker, ensuring your application behaves the same everywhere.
  • Efficiency: Containers share the same OS kernel, making them more lightweight and faster to start than virtual machines.
  • Scalability: Docker makes it easy to scale applications, allowing you to manage workloads efficiently.

Prerequisites

Before you begin, ensure that you have:

  • A system running Ubuntu (20.04 or later is recommended).
  • Sudo privileges to install software.

Installing Docker with a Single Command

The beauty of modern package management is that it simplifies complex installations. For Docker, you can use the get.docker.com script to install Docker with a single command. Here's how:

  1. Open Terminal: First, open your terminal. You can do this by searching for "Terminal" in your applications or using the shortcut Ctrl + Alt + T.
  2. Run the Installation Command: Copy and paste the following command into your terminal and hit Enter: curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh
    This command does the following:
    • curl -fsSL https://get.docker.com -o get-docker.sh: Downloads the Docker installation script from the official Docker website.
    • sh get-docker.sh: Executes the script to install Docker on your system.
  3. Verify the Installation: Once the installation is complete, verify that Docker is installed correctly by running: docker --version
    You should see the Docker version number, confirming that Docker is installed and ready to use.

Post-Installation Steps

To ensure you can run Docker commands without using sudo, add your user to the Docker group:

  1. Add User to Docker Group:bashCopy codesudo usermod -aG docker $USER
  2. Log Out and Back In: For the changes to take effect, log out and back in, or restart your system.
  3. Test Docker: Run a simple Docker command to test your setup: docker run hello-world
    This command downloads a test image and runs it in a container. If everything is set up correctly, you'll see a "Hello from Docker!" message.

Conclusion

And there you have it! With just a single command, you've installed Docker on your Ubuntu system. You're now ready to start building and deploying applications in containers. Whether you're a seasoned developer or just getting started, Docker is a tool that can greatly enhance your development workflow. Happy Dockering!