TitleDocker and Docker-Compose Installation Guide2025-04-01 22:48
Name Level 10

Docker and Docker-Compose Installation Guide

 

 

 

Docker] Docker의 개념 및 핵심 설명

 

 

 

A. Installing Docker

 

1. Update the system

sudo apt-get update -y

sudo apt-get upgrade -y

 

2. Install dependency packages sudo apt install apt-transport-https ca-certificates curl software-properties-common -y

 

3. Add Docker GPG Key

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

 

4. Set up 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

 

5. Install Docker

sudo apt update

sudo apt install docker-ce docker-ce-cli containerd.io

 

6. Start and enable Docker

sudo systemctl start docker

sudo systemctl enable docker

 

7. Check Docker status

sudo systemctl status docker

If the status shows active (running), Docker is working correctly.

 

8. Verify Docker installation sudo docker run hello-world

If the command runs successfully, Docker has been installed correctly.

 

 

B. Installing Docker-Compose

1. Download and install Docker-Compose

sudo curl -L "https://github.com/docker/compose/releases/download/v2.29.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

The latest version of Docker-Compose can be checked at https://github.com/docker/compose/releases

 

2. Grant execution permission

sudo chmod +x /usr/local/bin/docker-compose

 

3. Verify installation

docker-compose --version

If the installed version appears, Docker-Compose has been installed successfully.

 

 

C. Fixing Docker-Compose CURL Error When installing Docker-Compose on Ubuntu 22.04,

the following error may occur:

Failed to create the file /usr/local/bin/docker-compose: No such file or directory curl: (23) Failure writing output to destination

 

Cause:

This error occurs because the /usr/local/bin directory does not exist.

 

Solution:

1. Create the /usr/local/bin directory: sudo mkdir -p /usr/local/bin

2. Re-run the CURL command from Step B-1 to install Docker-Compose successfully.

 

 

D. Granting Docker Permissions

To run Docker without using sudo, grant access permissions with the following command:

sudo chmod 666 /var/run/docker.sock

 

After executing this command, non-root users can run Docker without sudo.