Docker 서버 구성 - 설치, 권한 설정 및 확인(Ubuntu 22.04.3 LTS)

2024. 2. 4. 16:23·Docker

구성 정보

  • OS: Ubuntu 22.04.3 LTS
  • 일반 계정에 sudo 권한으로 설치 진행

 

Docker 서버 구성

필요 패키지 패키지 설치

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

 

 

도커 공식 GPG키 등록

$ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/docker.gpg
$ pwd
/etc/apt/trusted.gpg.d
$ ls -al
-rw-r--r-- 1 root root 2760 Feb  4 06:57 docker.gpg

 

 

도커 공식 apt 저장소 추가

$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Repository: 'deb [arch=amd64] https://download.docker.com/linux/ubuntu jammy stable'
Description:
Archive for codename: jammy components: stable
More info: https://download.docker.com/linux/ubuntu
Adding repository.
Press [ENTER] to continue or Ctrl-c to cancel.
Adding deb entry to /etc/apt/sources.list.d/archive_uri-https_download_docker_com_linux_ubuntu-jammy.list
Adding disabled deb-src entry to /etc/apt/sources.list.d/archive_uri-https_download_docker_com_linux_ubuntu-jammy.list
Get:1 https://download.docker.com/linux/ubuntu jammy InRelease [48.8 kB]
Get:2 https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages [26.1 kB]
Hit:3 http://archive.ubuntu.com/ubuntu jammy InRelease
Hit:4 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:5 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Hit:6 http://archive.ubuntu.com/ubuntu jammy-security InRelease
Fetched 74.9 kB in 2s (45.7 kB/s)
Reading package lists... Done

 

 

도커 설치

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

 

 

설치 확인

$ systemctl status docker
● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2024-02-04 07:03:46 UTC; 3min 6s ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 2177 (dockerd)
      Tasks: 13
     Memory: 89.1M
        CPU: 582ms
     CGroup: /system.slice/docker.service
             └─2177 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

 

 

 

Docker 권한 설정

Docker 운영에 사용할 일반 계정에 관리자 권한 부여

 

도커 그룹 생성

$ sudo groupadd docker
groupadd: group 'docker' already exists

기존에 생성되어 있던 그룹이라 메시지 무시

 

 

현재 사용자를 도커 그룹에 포함

$ sudo usermod -aG docker $USER

 

 

접근 오류가 발생하지 않도록 권한 설정

$ sudo chmod 666 /var/run/docker.sock

 

 

도커 서비스 재시작

$ sudo systemctl restart docker

 

 

명령어 실행 확인

$ docker ps -a
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

 

 

Docker 실행

도커 실행

정상가동 확인을 위해 hello-world 라는 이미지로 도커  컨터이너 구동

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete
Digest: sha256:4bd78111b6914a99dbc560e6a20eab57ff6655aea4a80c50b0c5491968cbc2e6
Status: Downloaded newer image for hello-world:latest

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/

 

실행 된 컨테이너 확인

$ docker ps -a
CONTAINER ID   IMAGE         COMMAND    CREATED         STATUS                     PORTS     NAMES
f22f38a2f2c6   hello-world   "/hello"   2 minutes ago   Exited (0) 2 minutes ago             determined_gagarin

 

도커 설치 정보 확인

$ docker info
Client: Docker Engine - Community
 Version:    25.0.2
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.12.1
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.24.5
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 1
  Running: 0
  Paused: 0
  Stopped: 1
 Images: 1
 Server Version: 25.0.2
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.15.0-92-generic
 Operating System: Ubuntu 22.04.3 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 976.2MiB
 Name: docker
 ID: 29bbe969-5075-41e9-8172-cacded64891e
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

 

저작자표시 비영리 변경금지 (새창열림)
'Docker' 카테고리의 다른 글
  • Docker attach 와 exec 차이점
  • 컨테이너로 이미지 생성
  • 우분투 컨테이너 구성
  • [Docker] CentOS 7 docker 설치
기억보다는 기록을...
기억보다는 기록을...
내가 보려고 정리하는 글..
  • 기억보다는 기록을...
    메모장
    기억보다는 기록을...
    • 분류 전체보기
      • 클라우드(Azure, AWS, Alibaba)
      • 모니터링(Zabbix,Grafana)
      • 가상화(VMWare, Hyper-V)
      • Docker
      • Ansible
      • Linux
      • Windows
      • 이것저것
      • SQL
      • -------------------------
      • 재테크
  • 전체
    오늘
    어제
  • hELLO· Designed By정상우.v4.10.2
기억보다는 기록을...
Docker 서버 구성 - 설치, 권한 설정 및 확인(Ubuntu 22.04.3 LTS)
상단으로

티스토리툴바