Overview
During the initial setup, you made two main changes to your host system:- Granted Docker containers access to your display server with
xhost - Added your user to the
dockergroup to run Docker withoutsudo
Revoking Display Access
Revoke xhost Permissions
Remove Docker’s access to your display server:This immediately revokes the permission granted by
xhost +local:docker.Remove from Startup Scripts
If you added
xhost +local:docker to any startup scripts, remove those lines:After revoking display access, containers will no longer be able to open graphical windows on your display.
Removing User from Docker Group
Remove Group Membership
Remove your user from the This command removes the current user from the
docker group:docker group.Log Out and Back In
For the change to take effect, you must log out and log back in, or reboot the system:
Verify Removal
After logging back in, verify you’re no longer in the docker group:The command should return nothing if you were successfully removed.
Docker Socket Permission Restoration
The correct and secure way to run Docker withoutsudo is to add your user to the docker group, not to change socket permissions.
If You Accidentally Changed Socket Permissions
If you previously and incorrectly changed the Docker socket permissions, restore the defaults:Restore Default Permissions
The default permissions are usually
660 with owner root and group docker:Verify Permissions
Check that permissions are correctly set:Expected output:
srw-rw----means permissions are660(read/write for owner and group only)- Owner:
root - Group:
docker
Why chmod 666 is Dangerous
Understanding the security risk
Understanding the security risk
What
chmod 666 does:- Gives read and write permissions to everyone (owner, group, and all other users)
- Allows any user on the system to control Docker
- Effectively grants root access to all users
- Any user can run containers with root privileges
- Attackers with limited access can escalate to root
- Malicious processes can access Docker without authorization
- Use
chmod 660(default): Only root and docker group members can access - Add trusted users to the
dockergroup: Controlled access management - Log out/log in for group changes to take effect: Proper security boundaries
Complete Cleanup Procedure
To fully revert all changes and restore your system to its pre-container state:Clean Startup Scripts
Remove any
xhost +local:docker lines from:~/.profile~/.xinitrc~/.xprofile~/.bash_profile- Any other shell or session startup files