🥳
DevOps
  • Intro
  • Docker
    • Installing Docker and Docker Compose on an Ubuntu server:
    • Cannot perform an interactive login from a non TTY device
  • Git & Github
    • Auto-merge in github
    • Basic Recon with github actions
  • Dotnet
    • Amazon Lightsail for ASP.NET Core
    • AWS CodeBuild DotNet Core
    • Dotnet runtime: 7.0.2
    • Unable to locate package dotnet-sdk-8.0
    • Deploy a Dotnet Web on Ubuntu with Nginx Reserve Proxy
    • Unexpected Absence of .NET Core Runtime
    • Dotnet Runtime Missing (Solved)
  • Nginx
    • Service deployment and monitoring
    • Connection reset by peer
    • Deploy APIs on Nginx webserver in Ubuntu
    • Hide Nginx Server Info
    • Issuing SSL Certificate
    • Understanding SameSite cookies
    • Apache Tomcat
  • Ansible
    • Introduction
    • Ansible modules
    • Ansible Playbook
    • Handle lots of servers at one time
  • Jenkins
    • Attach trivy report on email (jenkins pipeline)
    • ng not found error while docker build in jenkins pipeline (script)
    • Auto Trigger Jenkins Build /Jobs with github webhook
    • Gradle for jenkins
  • Terraform
    • Terraform installation
    • Install jenkins docker image with Terraform
  • AWS
    • Hands-on labs
      • EC2 instance using AWS CLI
      • How to Create a Security Group
      • How to Create an AWS GP3 Volume
      • Subnet Creation Guide
      • Allocate Elastic IP
      • Create EC2 Instance Guide
      • Switching EC2 Instance Type
      • Assign Elastic IP to EC2 Instance
      • Enable EC2 Instance Termination Protection
      • Attach ENI to EC2 Instance Easily
      • Attach AWS Volume to EC2 Instance
      • How to Stop an Amazon EC2 Instance
      • How to Create an IAM User
      • EC2 Console Read-Only IAM Policy
      • How to Attach IAM Policy to User
      • Create EC2 IAM Role with Policy Guide
      • How to Delete an IAM Group
      • How to Delete an IAM Role
      • Private S3 Bucket Setup Guide
      • How to Create Public S3 Bucket
      • Enable S3 Bucket Versioning
      • Move Data into Existing S3 Bucket
      • Manage S3 Bucket Data Efficiently
      • Public RDS Instance Guide
      • Snapshot Creation for RDS Instances
      • Upgrade MySQL in RDS Using AWS Console
      • Remove RDS Instance Safely
      • How to Create a VPC
      • Understanding VPC CIDR
      • VPC IPv6 Implementation Guide
      • Create Private S3 Bucket Using AWS CLI
      • AWS CLI: Launch EC2 Instance Guide
      • Change EC2 Instance Type Using AWS CLI
      • AWS CLI: Delete EC2 Instance Guide
      • Host Apps on EC2 with Elastic IP
      • Host Apps on EC2 with Elastic IP
      • Increase EC2 Storage for Development
      • Launch EC2 Instances with Custom AMIs
      • Application Load Balancer Setup for EC2
      • EC2 Instance Setup and Cloud Watch Alarm
      • Set Up EC2 Web Server with Nginx
      • Migrate S3 Buckets with AWS CLI
      • Private RDS Setup for Development Projects
      • RDS Instance: Allow Public Access
      • Set Up Public VPC and EC2 for Internet Access
    • Install the CodeDeploy agent for Ubuntu Server
    • S3 Bucket Misconfiguration
    • Cloud Security Resources
    • Extend a Linux file system after resizing a volume
    • userdata for instances
    • Amazon EC2 User Data Scripts Dashboard
    • Patch Manager
  • Apache Solr
    • Introduction
    • Data Import Handler (DIH)
    • Create Core & Add Data in Solr
    • Import csv, xml data & Delete data
  • Kubernetes
    • K8s
    • Deploying Pods in Kubernetes Made Easy
    • Kubernetes Deployment for App Deployment
    • Kubernetes: Setup Namespaces and PODs
    • Kubernetes Pod Resource Limiting Guide
    • Kubernetes Pod Resource Limiting Guide
    • Kubernetes Rolling Updates Guide
    • Revert Deployment to Previous Version
    • Kubernetes Cronjob Scheduling Guide
    • Kubernetes Countdown Job Setup Guide
    • Kubernetes Time Check Pod Setup Guide
  • Prometheus & Grafana
    • Prometheus Installation
    • Grafana Installation
    • Telegraf
    • Influx DB
    • Prometheus alert rules
    • Config sysinfo-web
  • Splunk
    • Introduction
    • Uses of Splunk
    • Install Splunk on AWS EC2 Instance
    • Indexes in Splunk
      • Basic Searching
  • Linux Security
    • Package in linux
    • ICMP vulnerability:
    • Tunnelmole
  • Wazuh
    • Introduction
    • Creating an infra using Terraform
    • Manually creating aws infra
    • Ansible servers
    • Ansible (master with worker)
    • Wazuh manager and agent
    • Kibana
Powered by GitBook
On this page
  • Installing Docker on Ubuntu:
  • Automation Script:
  1. Docker

Installing Docker and Docker Compose on an Ubuntu server:

Installing Docker and Docker Compose on an Ubuntu server:

PreviousDockerNextCannot perform an interactive login from a non TTY device

Last updated 1 year ago

Installing Docker on Ubuntu:

  1. Update Package Index:

    sudo apt update
  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
  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 -
  4. Set Up the Stable Repository: Add the Docker repository to APT sources:

    sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  5. Update the Package Database: Update the package database with Docker packages from the newly added repo:

    sudo apt update
  6. Install Docker CE: Install Docker Community Edition (CE):

    sudo apt install docker-ce
  7. Verify Docker Installation: Check that Docker is installed correctly by running the hello-world image:

    sudo docker run hello-world

Installing Docker Compose:

  1. Download Docker Compose Binary:

    • Check the latest release of Docker Compose from the .

    • Replace VERSION with the latest release version:

    sudo curl -L "https://github.com/docker/compose/releases/download/VERSION/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  2. Apply Executable Permissions:

    sudo chmod +x /usr/local/bin/docker-compose
  3. Create Symbolic Link:

    sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
  4. Verify Docker Compose Installation:

    docker-compose --version

Post-Installation Steps:

  1. Manage Docker as a Non-root User (Optional):

    • If you want to run Docker commands without sudo, add your user to the docker group:

    sudo usermod -aG docker $USER
    • Log out and log back in to apply the group membership changes.

  2. Restart Docker Service:

    sudo systemctl restart docker
  3. Test Docker Compose:

    • Create a docker-compose.yml file in your project directory.

    • Define services and configurations in the docker-compose.yml.

    • Run docker-compose up to start the services defined in the YAML file.

Automation Script:

#!/bin/bash

# Install Docker
sudo apt update
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt install -y docker.io

# Install Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

# Add current user to the docker group
sudo usermod -aG docker $USER

# Prompt user to log out and log back in to apply group membership changes
echo "Please log out and log back in to apply group membership changes."

Save the script to a file, for example, install_docker.sh, then make it executable:

chmod +x install_docker.sh

To execute the script, run:

./install_docker.sh

Conclusion:

You have now successfully installed Docker and Docker Compose on your Ubuntu server. This setup enables you to manage and deploy containerized applications efficiently.

official GitHub repository