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 docker and add users to it. When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group.
Note: The docker group is equivalent to the root user;
To create the docker group and add your user:
Log into Ubuntu as a user with sudo privileges.
This procedure assumes you log in as the ubuntu user.
Create the docker group and add your user.
$ sudo usermod -aG docker ubuntu
Log out and log back in.
This ensures your user is running with the correct permissions.
Verify your work by running docker without sudo.
$ docker run hello-world
To avoid having to use sudo when you use the docker command, create a Unix group called docker and add users to it. When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group.
Note: The docker group is equivalent to the root user;
To create the docker group and add your user:
Log into Ubuntu as a user with sudo privileges.
This procedure assumes you log in as the ubuntu user.
Create the docker group and add your user.
$ sudo usermod -aG docker ubuntu
Log out and log back in.
This ensures your user is running with the correct permissions.
Verify your work by running docker without sudo.
$ docker run hello-world
Comments
Post a Comment