Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
113
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

Dockerを一般ユーザで実行する

概要

Dockerを一般ユーザで実行しようとすると、次のようなエラーが発生する。

$ docker info
FATA[0000] Get http:///var/run/docker.sock/v1.18/info: dial unix /var/run/docker.sock: permission denied. Are you trying to connect to a TLS-enabled daemon without TLS?

問題を回避するには、毎回sudoを行うか、対象ユーザをdockerグループに所属させる必要がある。

前提条件

  • Vagrant 1.7.2
  • Guest OS: CentOS 7.0

実行手順

一般ユーザvagrantをdockerグループに所属させる方法を紹介する。

$ sudo groupadd docker
$ sudo usermod -g docker vagrant
$ sudo /bin/systemctl restart docker.service

$ exit

一度コンソールから抜けた後、再度vagrant sshでログインする。

# 一般ユーザでdockerコマンドを実行できることを確認
$ docker info
Containers: 3
Images: 73
Storage Driver: devicemapper
 Pool Name: docker-253:1-8938407-pool
 Pool Blocksize: 65.54 kB
 Backing Filesystem: xfs
 Data file:
 Metadata file:
 Data Space Used: 2.758 GB
 Data Space Total: 107.4 GB
 Data Space Available: 104.6 GB
 Metadata Space Used: 4.661 MB
 Metadata Space Total: 2.147 GB
 Metadata Space Available: 2.143 GB
 Udev Sync Supported: true
 Library Version: 1.02.93-RHEL7 (2015-01-28)
Execution Driver: native-0.2
Kernel Version: 3.10.0-229.1.2.el7.x86_64
Operating System: CentOS Linux 7 (Core)
CPUs: 2
Total Memory: 993.5 MiB
Name: localhost.localdomain
ID: TOEB:TVTL:MLJ7:TYAH:PHAP:TZUU:XXOL:ANQM:TPL6:FGZQ:U36R:UI6Y
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
113
Help us understand the problem. What are the problem?