OpenSource/Docker

Ubuntu에 Docker 설치하기

Min 2022. 1. 20. 12:47

앞서 VMware에 Ubuntu까지 설치를 완료했다.

 

저는 Ubuntu 20.04.3 LTS 버전으로 설치했습니다.

 

Docker 설치

curl -fsSL https://get.docker.com/ | sudo sh

 

sudo 없이 Docker 사용하기

docker 는 기본적으로 root 권한으로 실행되기 되는데 일반적으로 root 로 작업하는 경우는 없다.
그래서 sudo 가 함께 사용되는데 번거롭기 때문에 아래와 같이 docker 그룹에 docker 를 사용할
일반계정을 추가한다.

$ sudo usermod -aG docker $USER
$ sudo usermod -aG docker your-user

 

Docker 설치 확인

ubuntu@ubuntu:~$ docker version
Client: Docker Engine - Community
 Version:           20.10.12
 API version:       1.41
 Go version:        go1.16.12
 Git commit:        e91ed57
 Built:             Mon Dec 13 11:45:33 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.12
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.12
  Git commit:       459d0df
  Built:            Mon Dec 13 11:43:42 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.12
  GitCommit:        7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc:
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

만약 permission denied 메세지가 뜬다면, 아래 글을 참고하시면 됩니다.

https://minkr.tistory.com/23

 

Docker설치 후 permission denied 발생하는 경우

Docker 설치 후 사용자를 docker그룹에 추가했는데, docker version을 치니 아래와 같은 메세지가 떴다. permission denied가 떴을 때 해결하는 방법을 알아보자. 방법은 두 가지가 있다. /var/run/docker.sock ..

minkr.tistory.com

 

Docker 데몬 실행

$ sudo systemctl start docker

 

Docker Container 실행하기

컨테이너를 실행하는 옵션은 매우 다양한다. 정상설치 확인을 위해 hello-wolrd 라는 이미지를 실행해 보았다.

$ docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/


컨테이너 hello-world 를 실행하면 어떻게 실행이되고 결과가 출력되는지 설명이 나오며
이후 종료를 하게 된다.