Linux에서 docker에 대한 사용자 구성

Linux에서 docker에 대한 사용자 구성

Linux Centos7환경에 도커를 설치했습니다 .

docker 명령을 실행할 수 있습니다 sudo.

[xyz@innolx20122 ~]$ sudo 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/

root비사용자로 실행하고 싶습니다 . 그래서 공식 문서를 따랐습니다.

처음에 나는 그 그룹에 합류했다.docker

[xyz@innolx20122 ~]$ sudo groupadd docker

사용자를 추가하려고 하면 'xyz'이런 메시지가 나타납니다. 내가 뭐 잘못 했어요?

[xyz@innolx20122 ~]$ sudo usermod -aG docker $xyz
Usage: usermod [options] LOGIN

Options:
  -c, --comment COMMENT         new value of the GECOS field
  -d, --home HOME_DIR           new home directory for the user account
  -e, --expiredate EXPIRE_DATE  set account expiration date to EXPIRE_DATE
  -f, --inactive INACTIVE       set password inactive after expiration
                                to INACTIVE
  -g, --gid GROUP               force use GROUP as new primary group
  -G, --groups GROUPS           new list of supplementary GROUPS
  -a, --append                  append the user to the supplemental GROUPS
                                mentioned by the -G option without removing
                                the user from other groups
  -h, --help                    display this help message and exit
  -l, --login NEW_LOGIN         new value of the login name
  -L, --lock                    lock the user account
  -m, --move-home               move contents of the home directory to the
                                new location (use only with -d)
  -o, --non-unique              allow using duplicate (non-unique) UID
  -p, --password PASSWORD       use encrypted password for the new password
  -R, --root CHROOT_DIR         directory to chroot into
  -P, --prefix PREFIX_DIR       prefix directory where are located the /etc/* files
  -s, --shell SHELL             new login shell for the user account
  -u, --uid UID                 new UID for the user account
  -U, --unlock                  unlock the user account
  -v, --add-subuids FIRST-LAST  add range of subordinate uids
  -V, --del-subuids FIRST-LAST  remove range of subordinate uids
  -w, --add-subgids FIRST-LAST  add range of subordinate gids
  -W, --del-subgids FIRST-LAST  remove range of subordinate gids
  -Z, --selinux-user SEUSER     new SELinux user mapping for the user account

그 후 나는 다음을 실행했습니다.

[xyz@innolx20122 ~]$ docker run hello-world
/usr/bin/docker-current: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.26/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
See '/usr/bin/docker-current run --help'.

나는 다음과 같이 사용자를 추가하려고 시도했습니다.

[xyz@innolx20122 ~]$ sudo usermod -aG docker xyz

그런 다음 시도했습니다.

sudo systemctl restart docker

여전히 같은 문제가 있습니다. 루트나 sudo 없이는 docker 명령을 실행할 수 없습니다.

관련 정보