//
Search
Duplicate
πŸ•’

Install Docker Engine on Ubuntu

Prerequisites
OS requirements
Ubuntu Jammy 22.04 (LTS) Ubuntu Impish 21.10 Ubuntu Focal 20.04 (LTS) Ubuntu Bionic 18.04 (LTS)
Shell
볡사
Set up the repository
1.
HTTPSλ₯Ό ν†΅ν•΄μ„œ Repositoryλ₯Ό μ‚¬μš©ν•  수 있게 μ„€μ •ν•˜κ³  νŒ¨ν‚€μ§€ 인덱슀λ₯Ό μ—…λ°μ΄νŠΈ 및 μ„€μΉ˜ν•©λ‹ˆλ‹€.
$ sudo apt-get update Hit:1 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy InRelease Get:2 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-updates InRelease [114 kB] Get:3 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-backports InRelease [99.8 kB] Get:4 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy/universe amd64 Packages [14.1 MB] Get:5 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB] Get:6 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy/universe Translation-en [5652 kB] Get:7 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy/universe amd64 c-n-f Metadata [286 kB] Get:8 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy/multiverse amd64 Packages [217 kB] Get:9 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy/multiverse Translation-en [112 kB] Get:10 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy/multiverse amd64 c-n-f Metadata [8372 B] Get:11 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [598 kB] Get:12 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-updates/main Translation-en [141 kB] Get:13 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-updates/main amd64 c-n-f Metadata [8632 B] Get:14 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-updates/restricted amd64 Packages [330 kB] Get:15 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-updates/restricted Translation-en [51.3 kB] Get:16 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages [422 kB] Get:17 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-updates/universe Translation-en [106 kB] Get:18 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 c-n-f Metadata [4404 B] Get:19 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-updates/multiverse amd64 Packages [7220 B] Get:20 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-updates/multiverse Translation-en [2360 B] Get:21 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-updates/multiverse amd64 c-n-f Metadata [420 B] Get:22 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-backports/main amd64 Packages [3008 B] Get:23 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-backports/main Translation-en [1432 B] Get:24 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-backports/main amd64 c-n-f Metadata [272 B] Get:25 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-backports/restricted amd64 c-n-f Metadata [116 B] Get:26 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-backports/universe amd64 Packages [6752 B] Get:27 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-backports/universe Translation-en [9240 B] Get:28 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-backports/universe amd64 c-n-f Metadata [352 B] Get:29 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-backports/multiverse amd64 c-n-f Metadata [116 B] Get:30 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages [339 kB] Get:31 http://security.ubuntu.com/ubuntu jammy-security/main Translation-en [78.4 kB] Get:32 http://security.ubuntu.com/ubuntu jammy-security/restricted amd64 Packages [298 kB] Get:33 http://security.ubuntu.com/ubuntu jammy-security/restricted Translation-en [46.3 kB] Get:34 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 Packages [282 kB] Get:35 http://security.ubuntu.com/ubuntu jammy-security/universe Translation-en [61.4 kB] Get:36 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 c-n-f Metadata [2408 B] Get:37 http://security.ubuntu.com/ubuntu jammy-security/multiverse amd64 Packages [4192 B] Get:38 http://security.ubuntu.com/ubuntu jammy-security/multiverse Translation-en [900 B] Get:39 http://security.ubuntu.com/ubuntu jammy-security/multiverse amd64 c-n-f Metadata [228 B] Fetched 23.5 MB in 3s (6781 kB/s) Reading package lists... Done $ sudo apt-get install ca-certificates curl gnupg lsb-release Reading package lists... Done Building dependency tree... Done Reading state information... Done ca-certificates is already the newest version (20211016). lsb-release is already the newest version (11.1.0ubuntu4). curl is already the newest version (7.81.0-1ubuntu1.4). gnupg is already the newest version (2.2.27-3ubuntu2.1). 0 upgraded, 0 newly installed, 0 to remove and 40 not upgraded.
Shell
볡사
2.
Docker official GPG Key
$ sudo mkdir -p /etc/apt/keyrings $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Shell
볡사
3.
Repository μ„€μ •
$ 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
Shell
볡사
Install Docker Engine
λ‹€μ‹œ ν•œλ²ˆ νŒ¨ν‚€μ§€ μ—…λ°μ΄νŠΈ μˆ˜ν–‰ 및 도컀 엔진 μ„€μΉ˜λ₯Ό μ§„ν–‰ν•©λ‹ˆλ‹€.
$ sudo apt-get update Hit:1 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy InRelease Hit:2 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-updates InRelease Hit:3 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-backports InRelease Get:4 https://download.docker.com/linux/ubuntu jammy InRelease [48.9 kB] Get:5 https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages [7065 B] Hit:6 http://security.ubuntu.com/ubuntu jammy-security InRelease Fetched 55.9 kB in 1s (100 kB/s) Reading package lists... Done $ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: docker-ce-rootless-extras docker-scan-plugin libltdl7 libslirp0 pigz slirp4netns Suggested packages: aufs-tools cgroupfs-mount | cgroup-lite The following NEW packages will be installed: containerd.io docker-ce docker-ce-cli docker-ce-rootless-extras docker-compose-plugin docker-scan-plugin libltdl7 libslirp0 pigz slirp4netns 0 upgraded, 10 newly installed, 0 to remove and 40 not upgraded. Need to get 109 MB of archives. After this operation, 423 MB of additional disk space will be used. Do you want to continue? [Y/n] Y
Shell
볡사
docker μ„€μΉ˜ 이후에 root κΆŒν•œμ΄ μ•„λ‹Œ 일반 μ‚¬μš©μž κΆŒν•œ(docker)으둜 κ΄€λ¦¬ν•˜κΈ° μœ„ν•œ μž‘μ—…μ„ μ§„ν–‰ν•©λ‹ˆλ‹€.
$ cat /etc/group | grep docker docker:x:999:
Shell
볡사
λ§Œμ•½ μ„€μΉ˜ 이후에 group νŒŒμΌμ— docker 정보가 μ—†λ‹€λ©΄ μ„€μΉ˜ κ³Όμ •μ—μ„œ μ—λŸ¬κ°€ λ°œμƒν•˜μ§€ μ•Šμ•˜λŠ”μ§€ ν™•μΈν•©λ‹ˆλ‹€. λ˜λŠ” docker λͺ…λ Ήμ–΄ μˆ˜ν–‰μ΄ 정상적인지 확인을 μ§„ν–‰ν•©λ‹ˆλ‹€.
ν˜„μž¬ μ‚¬μš©μžλ„ docker λͺ…λ Ήμ–΄λ₯Ό μ‚¬μš©ν•  수 있게 group λ‚΄μš©μ„ μˆ˜μ •ν•©λ‹ˆλ‹€.
$ sudo usermod -aG docker $USER $ cat /etc/group | grep docker docker:x:999:ubuntu
Shell
볡사
이후에 κΆŒν•œμ΄ μ μš©λλŠ”μ§€ ν™•μΈν•©λ‹ˆλ‹€.
$ sudo docker info Client: Context: default Debug Mode: false Plugins: app: Docker App (Docker Inc., v0.9.1-beta3) buildx: Docker Buildx (Docker Inc., v0.9.1-docker) compose: Docker Compose (Docker Inc., v2.10.2) scan: Docker Scan (Docker Inc., v0.17.0) Server: ERROR: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/info": dial unix /var/run/docker.sock: connect: permission denied errors pretty printing info
Shell
볡사
docker group에 ν¬ν•¨μ‹œμΌœ κΆŒν•œμ„ ν• λ‹Ήν–ˆμ§€λ§Œ μ‹€μ œ μ μš©μ€ μž¬μ ‘μ†μ„ ν•΄μ•Ό 적용이 λ©λ‹ˆλ‹€.
$ docker info Client: Context: default Debug Mode: false Plugins: app: Docker App (Docker Inc., v0.9.1-beta3) buildx: Docker Buildx (Docker Inc., v0.9.1-docker) compose: Docker Compose (Docker Inc., v2.10.2) scan: Docker Scan (Docker Inc., v0.17.0) Server: Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 20.10.18 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true userxattr: false Logging Driver: json-file Cgroup Driver: systemd Cgroup Version: 2 ...
Shell
볡사