50 lines
1.5 KiB
Markdown
50 lines
1.5 KiB
Markdown
### Installing Docker and Docker Compose on Ubuntu as Root
|
|
#### Preparation
|
|
```bash
|
|
sudo apt update
|
|
sudo apt upgrade -y
|
|
sudo apt install -y ca-certificates curl gnupg lsb-release
|
|
```
|
|
Update packages, upgrade system, install required dependencies.
|
|
|
|
#### Add Docker Repository
|
|
```bash
|
|
sudo mkdir -p /etc/apt/keyrings
|
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
|
sudo echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
```
|
|
Add Docker's official repository and its GPG key.
|
|
|
|
#### Install Docker
|
|
```bash
|
|
sudo apt update
|
|
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
|
```
|
|
Install Docker, its CLI, and required dependencies.
|
|
|
|
#### Verify Docker Installation
|
|
```bash
|
|
sudo docker run --rm hello-world
|
|
```
|
|
Run a test container to verify Docker installation.
|
|
|
|
### Run Docker as Non-Root
|
|
#### Configure Permissions
|
|
```bash
|
|
sudo groupadd docker
|
|
sudo usermod -aG docker $USER
|
|
```
|
|
Create a `docker` group and add the current user.
|
|
|
|
### Install Docker Compose
|
|
```bash
|
|
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
|
sudo chmod +x /usr/local/bin/docker-compose
|
|
```
|
|
Download and install the latest Docker Compose binary.
|
|
|
|
#### Verify Docker Compose Installation
|
|
```bash
|
|
docker-compose --version
|
|
```
|
|
Display the installed Docker Compose version. |