Ends in
00
days
00
hrs
00
mins
00
secs
ENROLL NOW

Azure Sale - Get Up to 25% OFF All Azure Reviewers

How to Install Docker on Ubuntu using Amazon EC2

Home » AWS » How to Install Docker on Ubuntu using Amazon EC2

How to Install Docker on Ubuntu using Amazon EC2

This tutorial will assist in setting up Docker on an Amazon EC2 Ubuntu instance. Docker’s containerization and Ubuntu’s user-friendliness make cloud application deployment and management simple. Amazon EC2 provides scalable infrastructure for hosting Docker containers, allowing for smooth app management and scaling. To easily set up Docker on your EC2 instance, just follow this tutorial.

What is Docker?

Docker is an open-source platform that simplifies the process of building, deploying, and managing applications within isolated containers. These containers bundle the application code along with all its dependencies, ensuring the software behaves the same across different environments, whether on a local machine or in the cloud.

Common uses:

  • Microservices
  • Continuous integration/continuous delivery (CI/CD) pipelines
  • Development and testing environments
  • Multi-cloud and hybrid-cloud setups

Example: A business can containerize its web app and database using Docker, ensuring that they run the same way on any server, regardless of the OS.

What is Ubuntu?

Ubuntu is a widely used, open-source operating system based on Linux. It is known for its ease of use, security, and versatility, making it popular for both personal computing and server environments.

Tutorials dojo strip

Common uses:

  • Desktop OS: Ubuntu is used on laptops and desktops for daily tasks like browsing and development.
  • Cloud and Servers: It is commonly used to run web servers, databases, and other services on cloud platforms such as AWS.
  • Development: Ubuntu is favored by developers due to its broad range of tools and libraries.

Example: Ubuntu is often the go-to operating system for cloud-based virtual machines (like Amazon EC2) and is popular among developers for building and deploying software.

Launching a new Ubuntu instance on AWS

  1. Open the AWS Management Console, then search for EC2.Searching for EC2
  2. Click Launch Instance. (Region: Seoul)Launch Instance
  3. Input the following details:
    • Name and tags: Docker Ubuntu Server
    • Application and OS Images: Ubuntu
    • Instance: t2.micro
    • Number of instances: 1
    • Key pair:
      • Click Create new key pair
      • Input the following details then click Create key pairCreate Key Pair
    • Leave the rest of the details as is
  4. Click Launch instance, then wait
  5. It should look like thisEC2 Dashboard

Installing Docker

  1. Select the instance then click ConnectConnect Button
  2. Click Connect againEC2 Instance Connect
  3. It should look like thisOnline Terminal
  4. Run the following commands (Should be in order):
    • Command: sudo apt-get update

      • Updates the package listDocker Install Command
    • Command: sudo apt-get install apt-transport-https ca-certificates curl software-properties-common -y
      • Installs required dependencies
  • Docker Install Command
    • Command: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
      • Adds Docker’s Official GPG Key
  • Docker Install Command
    • Command: 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
      • Adds Docker APT Repository
  • Docker Install Command
    • Command: sudo apt-get update
      • Updates the package database
  • Docker Install Command
    • Command: sudo apt-get install docker-ce docker-ce-cli containerd.io -y
      • Installs docker engine
  • Docker Install Command
    • Command: sudo docker --version
      • Verifies docker installation
  • Docker Install Command
    • Command: sudo docker run hello-world
      • To test if docker is running correctly
  • Docker Install Command
    • Command: sudo docker ps -a
      • To check all existing containers

Docker Install Command

Instance Termination

  1. Select the instance, then click Instance stateInstance State Dropdown
  2. Click Terminate (delete) instanceTerminate Instance
  3. Click Terminate (delete) when prompted for confirmationTerminate Instance Confirmation
  4. After terminating the instance, it remains visible for a while in a terminated state.Terminated State

Conclusion

By following the steps in this tutorial, you’ve successfully set up Docker on an Ubuntu-based Amazon EC2 instance as well as learn how to clean up the used resources. You can now efficiently manage, deploy, and scale your applications, with the use of both Docker and AWS. From here, you can now explore how to deploy containers and fix your infrastructure to meet your project needs.

Azure Sale – Get Up to 25% OFF All Azure Reviewers

Tutorials Dojo portal

Founder Spotlight: Jon Bonso

jon bonso

Enroll Now – Our Google Cloud Certification Exam Reviewers

Tutorials Dojo Exam Study Guide eBooks

tutorials dojo study guide eBook

FREE AWS Exam Readiness Digital Courses

Subscribe to our YouTube Channel

Tutorials Dojo YouTube Channel

FREE AWS, Azure, GCP Practice Test Samplers

Recent Posts

Written by: Alain Torno

Alain Andrei Torno is an AWS Certified Cloud Practitioner and an intern at Tutorials Dojo. He is the Backend Lead and Web Development Co-Head at AWS Cloud Club - PUP Manila. Currently, he is an undergraduate at Polytechnic University of the Philippines taking up Bachelors Degree in Information Technology.

AWS, Azure, and GCP Certifications are consistently among the top-paying IT certifications in the world, considering that most companies have now shifted to the cloud. Earn over $150,000 per year with an AWS, Azure, or GCP certification!

Follow us on LinkedIn, YouTube, Facebook, or join our Slack study group. More importantly, answer as many practice exams as you can to help increase your chances of passing your certification exams on your first try!

View Our AWS, Azure, and GCP Exam Reviewers Check out our FREE courses

Our Community

~98%
passing rate
Around 95-98% of our students pass the AWS Certification exams after training with our courses.
200k+
students
Over 200k enrollees choose Tutorials Dojo in preparing for their AWS Certification exams.
~4.8
ratings
Our courses are highly rated by our enrollees from all over the world.

What our students say about us?