Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Info
title목차

Table of Contents



설치된 Docker 삭제하기

Code Block
[sanse@Sprint1-Docker-vm ~]$ pwd
/home/sanse
[sanse@Sprint1-Docker-vm ~]$ sudo yum remove docker \
>                   docker-client \
>                   docker-client-latest \
>                   docker-common \
>                   docker-latest \
>                   docker-latest-logrotate \
>                   docker-logrotate \
>                   docker-engine

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for sanse:
Loaded plugins: fastestmirror, langpacks
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
[sanse@Sprint1-Docker-vm ~]$

...

Code Block
titlesudo yum install -y yum-utils \ > device-mapper-persistent-data \ > lvm2
linenumberstrue
collapsetrue
[sanse@Sprint1-Docker-vm ~]$ sudo yum install -y yum-utils \
>   device-mapper-persistent-data \
>   lvm2
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
base                                                                                                                                    | 3.6 kB  00:00:00
extras                                                                                                                                  | 3.4 kB  00:00:00
openlogic                                                                                                                               | 2.9 kB  00:00:00
updates                                                                                                                                 | 3.4 kB  00:00:00
(1/5): openlogic/7/x86_64/primary_db                                                                                                    |  76 kB  00:00:00
(2/5): base/7/x86_64/group_gz                                                                                                           | 166 kB  00:00:00
(3/5): extras/7/x86_64/primary_db                                                                                                       | 180 kB  00:00:00
(4/5): updates/7/x86_64/primary_db                                                                                                      | 2.4 MB  00:00:01
(5/5): base/7/x86_64/primary_db                                                                                                         | 6.0 MB  00:00:02
Package device-mapper-persistent-data-0.7.3-3.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package lvm2.x86_64 7:2.02.177-4.el7 will be updated
---> Package lvm2.x86_64 7:2.02.180-10.el7_6.3 will be an update
--> Processing Dependency: lvm2-libs = 7:2.02.180-10.el7_6.3 for package: 7:lvm2-2.02.180-10.el7_6.3.x86_64
---> Package yum-utils.noarch 0:1.1.31-46.el7_5 will be updated
---> Package yum-utils.noarch 0:1.1.31-50.el7 will be an update
--> Running transaction check
---> Package lvm2-libs.x86_64 7:2.02.177-4.el7 will be updated
---> Package lvm2-libs.x86_64 7:2.02.180-10.el7_6.3 will be an update
--> Processing Dependency: device-mapper-event = 7:1.02.149-10.el7_6.3 for package: 7:lvm2-libs-2.02.180-10.el7_6.3.x86_64
--> Running transaction check
---> Package device-mapper-event.x86_64 7:1.02.146-4.el7 will be updated
---> Package device-mapper-event.x86_64 7:1.02.149-10.el7_6.3 will be an update
--> Processing Dependency: device-mapper-event-libs = 7:1.02.149-10.el7_6.3 for package: 7:device-mapper-event-1.02.149-10.el7_6.3.x86_64
--> Processing Dependency: device-mapper = 7:1.02.149-10.el7_6.3 for package: 7:device-mapper-event-1.02.149-10.el7_6.3.x86_64
--> Running transaction check
---> Package device-mapper.x86_64 7:1.02.146-4.el7 will be updated
--> Processing Dependency: device-mapper = 7:1.02.146-4.el7 for package: 7:device-mapper-libs-1.02.146-4.el7.x86_64
---> Package device-mapper.x86_64 7:1.02.149-10.el7_6.3 will be an update
---> Package device-mapper-event-libs.x86_64 7:1.02.146-4.el7 will be updated
---> Package device-mapper-event-libs.x86_64 7:1.02.149-10.el7_6.3 will be an update
--> Running transaction check
---> Package device-mapper-libs.x86_64 7:1.02.146-4.el7 will be updated
---> Package device-mapper-libs.x86_64 7:1.02.149-10.el7_6.3 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================
 Package                                        Arch                         Version                                       Repository                     Size
===============================================================================================================================================================
Updating:
 lvm2                                           x86_64                       7:2.02.180-10.el7_6.3                         updates                       1.3 M
 yum-utils                                      noarch                       1.1.31-50.el7                                 base                          121 k
Updating for dependencies:
 device-mapper                                  x86_64                       7:1.02.149-10.el7_6.3                         updates                       292 k
 device-mapper-event                            x86_64                       7:1.02.149-10.el7_6.3                         updates                       188 k
 device-mapper-event-libs                       x86_64                       7:1.02.149-10.el7_6.3                         updates                       188 k
 device-mapper-libs                             x86_64                       7:1.02.149-10.el7_6.3                         updates                       320 k
 lvm2-libs                                      x86_64                       7:2.02.180-10.el7_6.3                         updates                       1.1 M

Transaction Summary
===============================================================================================================================================================
Upgrade  2 Packages (+5 Dependent packages)

Total download size: 3.5 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/7): device-mapper-event-1.02.149-10.el7_6.3.x86_64.rpm                                                                               | 188 kB  00:00:00
(2/7): device-mapper-1.02.149-10.el7_6.3.x86_64.rpm                                                                                     | 292 kB  00:00:00
(3/7): device-mapper-event-libs-1.02.149-10.el7_6.3.x86_64.rpm                                                                          | 188 kB  00:00:00
(4/7): device-mapper-libs-1.02.149-10.el7_6.3.x86_64.rpm                                                                                | 320 kB  00:00:00
(5/7): yum-utils-1.1.31-50.el7.noarch.rpm                                                                                               | 121 kB  00:00:00
(6/7): lvm2-2.02.180-10.el7_6.3.x86_64.rpm                                                                                              | 1.3 MB  00:00:01
(7/7): lvm2-libs-2.02.180-10.el7_6.3.x86_64.rpm                                                                                         | 1.1 MB  00:00:01
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                          1.5 MB/s | 3.5 MB  00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : 7:device-mapper-1.02.149-10.el7_6.3.x86_64                                                                                                 1/14
  Updating   : 7:device-mapper-libs-1.02.149-10.el7_6.3.x86_64                                                                                            2/14
  Updating   : 7:device-mapper-event-libs-1.02.149-10.el7_6.3.x86_64                                                                                      3/14
  Updating   : 7:device-mapper-event-1.02.149-10.el7_6.3.x86_64                                                                                           4/14
  Updating   : 7:lvm2-libs-2.02.180-10.el7_6.3.x86_64                                                                                                     5/14
  Updating   : 7:lvm2-2.02.180-10.el7_6.3.x86_64                                                                                                          6/14
  Updating   : yum-utils-1.1.31-50.el7.noarch                                                                                                             7/14
  Cleanup    : yum-utils-1.1.31-46.el7_5.noarch                                                                                                           8/14
  Cleanup    : 7:lvm2-2.02.177-4.el7.x86_64                                                                                                               9/14
  Cleanup    : 7:lvm2-libs-2.02.177-4.el7.x86_64                                                                                                         10/14
  Cleanup    : 7:device-mapper-event-1.02.146-4.el7.x86_64                                                                                               11/14
  Cleanup    : 7:device-mapper-event-libs-1.02.146-4.el7.x86_64                                                                                          12/14
  Cleanup    : 7:device-mapper-1.02.146-4.el7.x86_64                                                                                                     13/14
  Cleanup    : 7:device-mapper-libs-1.02.146-4.el7.x86_64                                                                                                14/14
  Verifying  : yum-utils-1.1.31-50.el7.noarch                                                                                                             1/14
  Verifying  : 7:device-mapper-libs-1.02.149-10.el7_6.3.x86_64                                                                                            2/14
  Verifying  : 7:device-mapper-event-libs-1.02.149-10.el7_6.3.x86_64                                                                                      3/14
  Verifying  : 7:device-mapper-event-1.02.149-10.el7_6.3.x86_64                                                                                           4/14
  Verifying  : 7:lvm2-libs-2.02.180-10.el7_6.3.x86_64                                                                                                     5/14
  Verifying  : 7:lvm2-2.02.180-10.el7_6.3.x86_64                                                                                                          6/14
  Verifying  : 7:device-mapper-1.02.149-10.el7_6.3.x86_64                                                                                                 7/14
  Verifying  : 7:lvm2-2.02.177-4.el7.x86_64                                                                                                               8/14
  Verifying  : yum-utils-1.1.31-46.el7_5.noarch                                                                                                           9/14
  Verifying  : 7:device-mapper-1.02.146-4.el7.x86_64                                                                                                     10/14
  Verifying  : 7:device-mapper-event-1.02.146-4.el7.x86_64                                                                                               11/14
  Verifying  : 7:device-mapper-event-libs-1.02.146-4.el7.x86_64                                                                                          12/14
  Verifying  : 7:lvm2-libs-2.02.177-4.el7.x86_64                                                                                                         13/14
  Verifying  : 7:device-mapper-libs-1.02.146-4.el7.x86_64                                                                                                14/14

Updated:
  lvm2.x86_64 7:2.02.180-10.el7_6.3                                              yum-utils.noarch 0:1.1.31-50.el7

Dependency Updated:
  device-mapper.x86_64 7:1.02.149-10.el7_6.3        device-mapper-event.x86_64 7:1.02.149-10.el7_6.3   device-mapper-event-libs.x86_64 7:1.02.149-10.el7_6.3
  device-mapper-libs.x86_64 7:1.02.149-10.el7_6.3   lvm2-libs.x86_64 7:2.02.180-10.el7_6.3

Complete!
[sanse@Sprint1-Docker-vm ~]$

...

Docker Repository 설정

Code Block
titlesudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
linenumberstrue
[sanse@Sprint1-Docker-vm ~]$ sudo yum-config-manager \
>     --add-repo \
>     https://download.docker.com/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror, langpacks
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[sanse@Sprint1-Docker-vm ~]$

...

Code Block
[sanse@Sprint1-Docker-vm ~]$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535
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/

[sanse@Sprint1-Docker-vm ~]$


Docker를 Non Root계정으로 관리하기

Code Block
[sanse@Sprint1-Docker-vm ~]$ sudo useradd -g docker docker

[sanse@Sprint1-Docker-vm ~]$ docker ps
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.39/containers/json: dial unix /var/run/docker.sock: connect: permission denied
[sanse@Sprint1-Docker-vm ~]$ sudo su - docker
[sudo] password for sanse:
[docker@Sprint1-Docker-vm ~]$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
[docker@Sprint1-Docker-vm ~]$


시스템 부팅시 Docker 자동 시작하기

Code Block
[sanse@Sprint1-Docker-vm ~]$ sudo systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[sanse@Sprint1-Docker-vm ~]$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2019-03-01 07:21:25 UTC; 25min ago
     Docs: https://docs.docker.com
 Main PID: 32584 (dockerd)
   CGroup: /system.slice/docker.service
           └─32584 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Mar 01 07:21:24 Sprint1-Docker-vm dockerd[32584]: time="2019-03-01T07:21:24.981249273Z" level=info msg="pickfirstBalancer: HandleSubConnStateChange:...ule=grpc
Mar 01 07:21:25 Sprint1-Docker-vm dockerd[32584]: time="2019-03-01T07:21:25.141678250Z" level=info msg="Graph migration to content-addressability to...seconds"
Mar 01 07:21:25 Sprint1-Docker-vm dockerd[32584]: time="2019-03-01T07:21:25.142862154Z" level=info msg="Loading containers: start."
Mar 01 07:21:25 Sprint1-Docker-vm dockerd[32584]: time="2019-03-01T07:21:25.534811366Z" level=info msg="Default bridge (docker0) is assigned with an...address"
Mar 01 07:21:25 Sprint1-Docker-vm dockerd[32584]: time="2019-03-01T07:21:25.674466569Z" level=info msg="Loading containers: done."
Mar 01 07:21:25 Sprint1-Docker-vm dockerd[32584]: time="2019-03-01T07:21:25.710416898Z" level=info msg="Docker daemon" commit=774a1f4 graphdriver(s)...=18.09.3
Mar 01 07:21:25 Sprint1-Docker-vm dockerd[32584]: time="2019-03-01T07:21:25.710752199Z" level=info msg="Daemon has completed initialization"
Mar 01 07:21:25 Sprint1-Docker-vm dockerd[32584]: time="2019-03-01T07:21:25.767784405Z" level=info msg="API listen on /var/run/docker.sock"
Mar 01 07:21:25 Sprint1-Docker-vm systemd[1]: Started Docker Application Container Engine.
Mar 01 07:23:58 Sprint1-Docker-vm dockerd[32584]: time="2019-03-01T07:23:58.655294539Z" level=info msg="ignoring event" module=libcontainerd namespa...kDelete"
Hint: Some lines were ellipsized, use -l to show in full.
[sanse@Sprint1-Docker-vm ~]$