Ubuntu2404 Install Docker and Docker Compose: Difference between revisions

From CompleteNoobs
Jump to navigation Jump to search
AwesomO (talk | contribs)
Created page with "=== Preparation === Before we begin, make sure you're logged in with a user account that has sudo privileges. === Update System Packages === Update your package list to ensure you have the latest versions of packages: <source lang="bash"> sudo apt update && sudo apt upgrade -y </source> === Install Docker Prerequisites === Install the necessary packages for Docker setup: <source lang="bash"> sudo apt install -y apt-transport-https ca-certificates curl software-pro..."
 
AwesomO (talk | contribs)
Line 47: Line 47:
   </source>
   </source>


<!--
* '''Install Docker Compose''':
* '''Install Docker Compose''':


Line 60: Line 61:
   sudo chmod +x /usr/local/bin/docker-compose
   sudo chmod +x /usr/local/bin/docker-compose
   </source>
   </source>
-->


=== Verify Installation ===
=== Verify Installation ===

Revision as of 14:40, 30 August 2025

Preparation

Before we begin, make sure you're logged in with a user account that has sudo privileges.

Update System Packages

Update your package list to ensure you have the latest versions of packages:

sudo apt update && sudo apt upgrade -y

Install Docker Prerequisites

Install the necessary packages for Docker setup:

sudo apt install -y apt-transport-https ca-certificates curl software-properties-common

Setup Docker Repository

  • Add Docker's Official GPG Key:
  curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
  • Add the Docker Repository:
  echo "deb [arch=$(dpkg --print-architecture) 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

Install Docker and Docker Compose

  • Update Package List Again:
  sudo apt update
  • Install Docker Engine, CLI, Containerd, and Additional Tools:
  sudo apt install -y docker-ce docker-ce-cli containerd.io python3-bs4 python3-requests docker-compose


Verify Installation

Check if Docker and Docker Compose are installed correctly:

docker --version
docker-compose --version

Configure User Permissions

To run Docker commands without sudo, add your user to the docker group:

sudo usermod -aG docker $USER

Note: After adding your user to the docker group, you'll need to log out and log back in for the changes to take effect. If you do not log out and back in, Or you do not add your $USER to the docker group, you will be required to use sudo in some cases. such as ..

a way to apply group changes without logging out and back in - tip:

exec sudo su -l $USER

This command will replace your current shell with a new login shell for your user, which will have the updated group memberships. Both of these methods will apply the group changes immediately, allowing you to use LXD commands without having to log out and back in.

Remember, these changes only apply to the current terminal session. If you open a new terminal window, you might need to run the command again or log out and back in for the changes to take effect system-wide.