Install and Run Docker on NON ROOT

https://docs.docker.com/installation/ubuntulinux/#giving-non-root-access

https://ubuntuincident.wordpress.com/2014/01/10/docker/


Create a docker group

The docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can access it with sudo. For this reason, docker daemon always runs as the root user.

To avoid having to use sudo when you use the docker command, create a Unix group called dockerand add users to it. When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group.

Warning: The docker group is equivalent to the root user; For details on how this impacts security in your system, see Docker Daemon Attack Surface for details.

To create the docker group and add your user:

  1. Log into Ubuntu as a user with sudo privileges.

    This procedure assumes you log in as the ubuntu user.

  2. Create the docker group and add your user.

    $ sudo usermod -aG docker ubuntu
  3. Log out and log back in.

    This ensures your user is running with the correct permissions.

  4. Verify your work by running docker without sudo.

    $ docker run hello-world



Execute docker as non-root
As you noticed, docker must be executed with sudo. If you want to execute it with your non-root account, here is what to do:

1
2
3
4
5
6
# create the 'docker' group
$ sudo groupadd docker  # probably it already exists
# add your user to the 'docker' group
$ sudo gpasswd -a USER docker  # replace USER with your user name
# restart the service
$ sudo service docker restart

You will have to log out and log back in to make the group settings active on your account. After that you can launch docker without sudo:

1
2
3
4
5
6
7
$ docker images
REPOSITORY          TAG                 ID                  CREATED             SIZE
ubuntu              12.04               8dbd9e392a96        4 months ago        131.5 MB (virtual 131.5 MB)
ubuntu              12.10               b750fe79269d        5 months ago        24.65 kB (virtual 180.1 MB)
ubuntu              latest              8dbd9e392a96        4 months ago        131.5 MB (virtual 131.5 MB)
ubuntu              precise             8dbd9e392a96        4 months ago        131.5 MB (virtual 131.5 MB)
ubuntu              quantal             b750fe79269d        5 months ago        24.65 kB (virtual 180.1 MB)







转载于:https://my.oschina.net/dexterman/blog/397450

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值