본문 바로가기

Docker

Docker Ubuntu Install 및 사용자 권한 설정

반응형
 

Install Docker Engine on Ubuntu

 

docs.docker.com

Uninstall old versions

Older versions of Docker were called docker, docker.io, or docker-engine. If these are installed, uninstall them:

$ sudo apt-get remove docker docker-engine docker.io containerd runc

 

Set up the repository

1. Update the apt package index and install packages to allow apt to use a repository over HTTPS:

$ sudo apt-get update

$ sudo apt-get install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

2. 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

3. Use the following command to set up the stable repository. To add the nightly or test repository, add the word nightly or test (or both) after the word stable in the commands below. Learn about nightly and test channels.

$ 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 Engine

  1. Update the apt package index, and install the latest version of Docker Engine and containerd, or go to the next step to install a specific version:
 $ sudo apt-get update
 $ sudo apt-get install docker-ce docker-ce-cli containerd.io

 

 

* sudo 없이 명령어 실행하기

Docker는 기본적으로 루트권한이 필요하므로 매번 sudo를 붙이거나 root 권한으로 사용해야 한다.

root로 사용하는 방법은 추천하지 않으므로 현재 사용중인 사용자를 docker 그룹에 등록을 해주도록 하자.

등록 후 해당 사용자 계정으로 재접속 하거나 재기동한다.

sudo usermod -aG docker [사용자]​

 

 

 

 

 

Install Docker Compose

 

docs.docker.com

Docker Compose 설치 

1. Run this command to download the current stable release of 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

 

2. Apply executable permissions to the binary:

 

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

 

3. 버전 확인

docker-compose -v
반응형