Ubuntu 22.04.4 LTS에 docker-ce를 설치합니다.
이 글의 내용
충돌하는 패키지 삭제
$ for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt remove $pkg; done
ubuntu@ip-172-26-4-232:~$ for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt remove $pkg; done Reading package lists... Done Building dependency tree... Done Reading state information... Done Package 'docker.io' is not installed, so not removed 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. ... Reading package lists... Done Building dependency tree... Done Reading state information... Done Package 'runc' is not installed, so not removed 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. ubuntu@ip-172-26-4-232:~$
apt 리포지토리 추가
$ sudo apt update $ sudo apt install ca-certificates curl $ sudo install -m 0755 -d /etc/apt/keyrings $ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc $ sudo chmod a+r /etc/apt/keyrings/docker.asc $ echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null $ sudo apt update
ubuntu@ip-172-26-4-232:~$ sudo apt update Hit:1 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy InRelease ... Get:42 http://security.ubuntu.com/ubuntu jammy-security/multiverse amd64 c-n-f Metadata [228 B] Fetched 32.3 MB in 6s (5638 kB/s) Reading package lists... Done ubuntu@ip-172-26-4-232:~$ sudo apt install ca-certificates curl Reading package lists... Done Building dependency tree... Done Reading state information... Done ca-certificates is already the newest version (20230311ubuntu0.22.04.1). ca-certificates set to manually installed. curl is already the newest version (7.81.0-1ubuntu1.16). curl set to manually installed. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. ubuntu@ip-172-26-4-232:~$ sudo install -m 0755 -d /etc/apt/keyrings ubuntu@ip-172-26-4-232:~$ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc ubuntu@ip-172-26-4-232:~$ sudo chmod a+r /etc/apt/keyrings/docker.asc ubuntu@ip-172-26-4-232:~$ echo \ > "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ > $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ > sudo tee /etc/apt/sources.list.d/docker.list > /dev/null ubuntu@ip-172-26-4-232:~$ sudo apt 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.8 kB] Hit:5 http://security.ubuntu.com/ubuntu jammy-security InRelease Get:6 https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages [35.6 kB] Fetched 84.4 kB in 1s (121 kB/s) Reading package lists... Done ubuntu@ip-172-26-4-232:~$
Docker Engine 설치
$ sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
ubuntu@ip-172-26-4-232:~$ sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin 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 libltdl7 libslirp0 pigz slirp4netns Suggested packages: aufs-tools cgroupfs-mount | cgroup-lite The following NEW packages will be installed: containerd.io docker-buildx-plugin docker-ce docker-ce-cli docker-ce-rootless-extras docker-compose-plugin libltdl7 libslirp0 pigz slirp4netns 0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded. Need to get 122 MB of archives. After this operation, 437 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy/universe amd64 pigz amd64 2.6-1 [63.6 kB] ... Get:10 https://download.docker.com/linux/ubuntu jammy/stable amd64 docker-compose-plugin amd64 2.28.1-1~ubuntu.22.04~jammy [12.5 MB] Fetched 122 MB in 3s (43.6 MB/s) Selecting previously unselected package pigz. (Reading database ... 65320 files and directories currently installed.) Preparing to unpack .../0-pigz_2.6-1_amd64.deb ... Unpacking pigz (2.6-1) ... ... No VM guests are running outdated hypervisor (qemu) binaries on this host. ubuntu@ip-172-26-4-232:~$
설치 확인
$ sudo docker run hello-world
ubuntu@ip-172-26-4-232:~$ sudo docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world c1ec31eb5944: Pull complete Digest: sha256:1408fec50309afee38f3535383f5b09419e6dc0925bc69891e79d84cc4cdcec6 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/ ubuntu@ip-172-26-4-232:~$