본문 바로가기
Project

[Docker] 도커 기본 설치(도커 엔진, DNS 설정)

by 테쿙 2024. 8. 13.

 

-Docker 이전 버전 제거

[root@localhost ~]# sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
No match for argument: docker
No match for argument: docker-client
No match for argument: docker-client-latest
No match for argument: docker-common
No match for argument: docker-latest
No match for argument: docker-latest-logrotate
No match for argument: docker-logrotate
No match for argument: docker-engine
No packages marked for removal.
Dependencies resolved.
Nothing to do.
Complete!

 

-저장소 설정

[root@localhost ~]# sudo yum install -y yum-utils
Last metadata expiration check: 0:09:01 ago on Mon 12 Aug 2024 09:22:31 AM UTC.
Package yum-utils-4.3.0-13.el9.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!
[root@localhost ~]# sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
Adding repo from: https://download.docker.com/linux/centos/docker-ce.repo

 

-도커 엔진 설치

[root@localhost ~]# sudo yum install docker-ce docker-ce-cli containerd.io
Docker CE Stable - x86_64                        195 kB/s |  53 kB     00:00    
Dependencies resolved.
=================================================================================
 Package                     Arch     Version           Repository          Size
=================================================================================
Installing:
 containerd.io               x86_64   1.7.19-3.1.el9    docker-ce-stable    43 M
 docker-ce                   x86_64   3:27.1.1-1.el9    docker-ce-stable    27 M
 docker-ce-cli               x86_64   1:27.1.1-1.el9    docker-ce-stable   7.8 M
Installing dependencies:
 container-selinux           noarch   3:2.229.0-1.el9   appstream           56 k
 fuse-overlayfs              x86_64   1.13-1.el9        appstream           66 k
 libslirp                    x86_64   4.4.0-7.el9       appstream           68 k
 slirp4netns                 x86_64   1.2.3-1.el9       appstream           46 k
Installing weak dependencies:
 docker-buildx-plugin        x86_64   0.16.1-1.el9      docker-ce-stable    14 M
 docker-ce-rootless-extras   x86_64   27.1.1-1.el9      docker-ce-stable   4.0 M
 docker-compose-plugin       x86_64   2.29.1-1.el9      docker-ce-stable    13 M

Transaction Summary
=================================================================================
Install  10 Packages

Total size: 109 M
Total download size: 109 M
Installed size: 422 M
Is this ok [y/N]: y
Downloading Packages:
[SKIPPED] container-selinux-2.229.0-1.el9.noarch.rpm: Already downloaded        
[SKIPPED] fuse-overlayfs-1.13-1.el9.x86_64.rpm: Already downloaded              
[SKIPPED] slirp4netns-1.2.3-1.el9.x86_64.rpm: Already downloaded                
[SKIPPED] libslirp-4.4.0-7.el9.x86_64.rpm: Already downloaded                   
(5/10): docker-buildx-plugin-0.16.1-1.el9.x86_64 8.5 MB/s |  14 MB     00:01    
(6/10): docker-ce-cli-27.1.1-1.el9.x86_64.rpm    6.9 MB/s | 7.8 MB     00:01    
(7/10): docker-ce-rootless-extras-27.1.1-1.el9.x 7.6 MB/s | 4.0 MB     00:00    
(8/10): docker-ce-27.1.1-1.el9.x86_64.rpm        6.7 MB/s |  27 MB     00:03    
(9/10): docker-compose-plugin-2.29.1-1.el9.x86_6  11 MB/s |  13 MB     00:01    
(10/10): containerd.io-1.7.19-3.1.el9.x86_64.rpm 9.3 MB/s |  43 MB     00:04    
---------------------------------------------------------------------------------
Total                                             23 MB/s | 109 MB     00:04     
Docker CE Stable - x86_64                         19 kB/s | 1.6 kB     00:00    
Importing GPG key 0x621E9F35:
 Userid     : "Docker Release (CE rpm) <docker@docker.com>"
 Fingerprint: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
 From       : https://download.docker.com/linux/centos/gpg
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                         1/1 
  Running scriptlet: container-selinux-3:2.229.0-1.el9.noarch               1/10 
  Installing       : container-selinux-3:2.229.0-1.el9.noarch               1/10 
  Running scriptlet: container-selinux-3:2.229.0-1.el9.noarch               1/10 
  Installing       : docker-compose-plugin-2.29.1-1.el9.x86_64              2/10 
  Running scriptlet: docker-compose-plugin-2.29.1-1.el9.x86_64              2/10 
  Installing       : containerd.io-1.7.19-3.1.el9.x86_64                    3/10 
  Running scriptlet: containerd.io-1.7.19-3.1.el9.x86_64                    3/10 
  Installing       : libslirp-4.4.0-7.el9.x86_64                            4/10 
  Installing       : slirp4netns-1.2.3-1.el9.x86_64                         5/10 
  Installing       : fuse-overlayfs-1.13-1.el9.x86_64                       6/10 
  Running scriptlet: fuse-overlayfs-1.13-1.el9.x86_64                       6/10 
  Installing       : docker-buildx-plugin-0.16.1-1.el9.x86_64               7/10 
  Running scriptlet: docker-buildx-plugin-0.16.1-1.el9.x86_64               7/10 
  Installing       : docker-ce-cli-1:27.1.1-1.el9.x86_64                    8/10 
  Running scriptlet: docker-ce-cli-1:27.1.1-1.el9.x86_64                    8/10 
  Installing       : docker-ce-rootless-extras-27.1.1-1.el9.x86_64          9/10 
  Running scriptlet: docker-ce-rootless-extras-27.1.1-1.el9.x86_64          9/10 
  Installing       : docker-ce-3:27.1.1-1.el9.x86_64                       10/10 
  Running scriptlet: docker-ce-3:27.1.1-1.el9.x86_64                       10/10 
  Running scriptlet: container-selinux-3:2.229.0-1.el9.noarch              10/10 



  Running scriptlet: docker-ce-3:27.1.1-1.el9.x86_64                       10/10 
  Verifying        : containerd.io-1.7.19-3.1.el9.x86_64                    1/10 
  Verifying        : docker-buildx-plugin-0.16.1-1.el9.x86_64               2/10 
  Verifying        : docker-ce-3:27.1.1-1.el9.x86_64                        3/10 
  Verifying        : docker-ce-cli-1:27.1.1-1.el9.x86_64                    4/10 
  Verifying        : docker-ce-rootless-extras-27.1.1-1.el9.x86_64          5/10 
  Verifying        : docker-compose-plugin-2.29.1-1.el9.x86_64              6/10 
  Verifying        : container-selinux-3:2.229.0-1.el9.noarch               7/10 
  Verifying        : fuse-overlayfs-1.13-1.el9.x86_64                       8/10 
  Verifying        : slirp4netns-1.2.3-1.el9.x86_64                         9/10 
  Verifying        : libslirp-4.4.0-7.el9.x86_64                           10/10 

Installed:
  container-selinux-3:2.229.0-1.el9.noarch                                       
  containerd.io-1.7.19-3.1.el9.x86_64                                            
  docker-buildx-plugin-0.16.1-1.el9.x86_64                                       
  docker-ce-3:27.1.1-1.el9.x86_64                                                
  docker-ce-cli-1:27.1.1-1.el9.x86_64                                            
  docker-ce-rootless-extras-27.1.1-1.el9.x86_64                                  
  docker-compose-plugin-2.29.1-1.el9.x86_64                                      
  fuse-overlayfs-1.13-1.el9.x86_64                                               
  libslirp-4.4.0-7.el9.x86_64                                                    
  slirp4netns-1.2.3-1.el9.x86_64                                                 

Complete!

 

-도커 시작

[root@localhost ~]# sudo systemctl start docker
[root@localhost ~]# 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/

 

-Linux 호스트 구성

[root@localhost ~]# useradd paas -m
[root@localhost ~]# passwd paas
Changing password for user paas.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]# sudo usermod -aG docker paas
[root@localhost ~]#
[root@localhost ~]# su - paas
Last login: Tue Aug 13 03:04:52 UTC 2024 on pts/0
[paas@localhost ~]$

 

-sudo 없이 명령어 확인

[paas@localhost ~]$ 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/

 

-docker 부팅 시 시작 설정

[root@localhost ~]# sudo systemctl enable docker.service
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
[root@localhost ~]# sudo systemctl enable containerd.service
Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → /usr/lib/systemd/system/containerd.service.

 

-dns 설정

[root@localhost ~]# sudo vi /etc/docker/daemon.json
[root@localhost ~]# sudo cat /etc/docker/daemon.json
{
"dns": ["8.8.8.8", "8.8.4.4"]
}
[root@localhost ~]# sudo service docker restart
Redirecting to /bin/systemctl restart docker.service
[root@localhost ~]# docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
Digest: sha256:1408fec50309afee38f3535383f5b09419e6dc0925bc69891e79d84cc4cdcec6
Status: Image is up to date for hello-world:latest
docker.io/library/hello-world:latest

 

'Project' 카테고리의 다른 글

[Docker] 도커 컨테이너 이미지 (Build, Push, Dockerhub)  (0) 2024.08.13