I am getting the following error,
The current user is not in the ‘docker-users’ group. Add yourself to
the ‘docker-users’ group and then log out and back in to Windows.
How do I resolve this error on Windows?
TAbdiukov
1,1833 gold badges12 silver badges25 bronze badges
asked Apr 30, 2020 at 19:02
coolblue2000coolblue2000
3,84810 gold badges42 silver badges64 bronze badges
2
Run this command from an administrator command window to add your user id to the docker-users group and log back into your user account for it to take effect.
net localgroup docker-users "your-user-id" /ADD
your-user-id
is your local Windows user name. You can determine this by looking at the folder name under C:\Users\ .
answered Aug 6, 2020 at 19:51
Pradyumna RevurPradyumna Revur
1,6311 gold badge5 silver badges3 bronze badges
11
It might occur that the user-group «docker-users» not exist on your machine. In that case enter the following commands in the Powershell
New-LocalGroup -Name 'docker-users' -Description 'docker Users Group'
Add-LocalGroupMember -Group 'Administrators' -Member ('docker-users') –Verbose
Add-LocalGroupMember -Group 'docker-users' -Member ('Username','Administrators') –Verbose
answered Oct 10, 2020 at 12:18
1
Try restarting the system, that worked for me, as it pushed me to the group automatically.
answered Jun 3, 2022 at 7:46
Raw_WishRaw_Wish
1631 silver badge6 bronze badges
If you are installing Docker Desktop from Chocolatey, you might only need a restart, as you are put in that group automatically.
answered Mar 18, 2022 at 9:11
cederlofcederlof
7,2164 gold badges45 silver badges63 bronze badges
In my case, I just uninstall and reinstall the docker. And it fine now.
answered Jun 10, 2022 at 7:47
Muhammad AwaisMuhammad Awais
4,2581 gold badge42 silver badges37 bronze badges
0
I am getting the following error,
The current user is not in the ‘docker-users’ group. Add yourself to
the ‘docker-users’ group and then log out and back in to Windows.
How do I resolve this error on Windows?
TAbdiukov
1,1833 gold badges12 silver badges25 bronze badges
asked Apr 30, 2020 at 19:02
coolblue2000coolblue2000
3,84810 gold badges42 silver badges64 bronze badges
2
Run this command from an administrator command window to add your user id to the docker-users group and log back into your user account for it to take effect.
net localgroup docker-users "your-user-id" /ADD
your-user-id
is your local Windows user name. You can determine this by looking at the folder name under C:\Users\ .
answered Aug 6, 2020 at 19:51
Pradyumna RevurPradyumna Revur
1,6311 gold badge5 silver badges3 bronze badges
11
It might occur that the user-group «docker-users» not exist on your machine. In that case enter the following commands in the Powershell
New-LocalGroup -Name 'docker-users' -Description 'docker Users Group'
Add-LocalGroupMember -Group 'Administrators' -Member ('docker-users') –Verbose
Add-LocalGroupMember -Group 'docker-users' -Member ('Username','Administrators') –Verbose
answered Oct 10, 2020 at 12:18
1
Try restarting the system, that worked for me, as it pushed me to the group automatically.
answered Jun 3, 2022 at 7:46
Raw_WishRaw_Wish
1631 silver badge6 bronze badges
If you are installing Docker Desktop from Chocolatey, you might only need a restart, as you are put in that group automatically.
answered Mar 18, 2022 at 9:11
cederlofcederlof
7,2164 gold badges45 silver badges63 bronze badges
In my case, I just uninstall and reinstall the docker. And it fine now.
answered Jun 10, 2022 at 7:47
Muhammad AwaisMuhammad Awais
4,2581 gold badge42 silver badges37 bronze badges
0
I just ran into this while trying to upgrade to 17.12.0-ce-win47
. That’s what I get for clicking the nice pretty upgrade button. Now, my user is already in the docker-users group. Yet, I can’t delete the Docker folder.. quite maddening. Time to dig through Windows security BS to get this fixed.
Access to the path 'C:\Program Files\Docker\Docker\Bugsnag.dll' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
at LightweightInstaller.UnpackArtifactsStep.<DoAsync>d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at LightweightInstaller.InstallWorkflow.<HandleD4WPackage>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at LightweightInstaller.InstallWorkflow.<ProcessAsync>d__18.MoveNext()
Since Docker announced a new subscription for Docker Desktop for personal use, educational institutions, non-commercial open-source projects and small businesses, other enterprises need to acquire licences for all installations of Docker Desktop.
So is there an alternative on Windows to continue to legally use containers with a docker command and a nice UI like VSCode without paying a licence : the answer is YES !
We are doing magic with Windows 10, Ubuntu on WSL2, docker builder cli for windows and a little elbow grease.
Big Thanks to Jonathan Bowman for his article.
I reused and I adapted it to make VisualCode working with dockerd under WSL2.
Installation on Windows
On your windows, you need to install a couple of things :
- WSL2 : Install WSL | Microsoft Docs
- Ubuntu on WSL2 : in Microsoft Store Ubuntu 20.04 LTS
- Visual Code : it can be downloaded at Visual Studio Code — Code Editing. Redefined
- Docker extension for VSCode : directly from Visual Code Extensions Marketplace
Installation of dockerd in WSL2/Ubuntu
(Inspired from the Jonathan Bowman’s article)
Is your user a «sudoer» ?
Check if sudo is installed if not : *apt install sudo*
`
grep -E ‘sudo|wheel’ /etc/group
You would see something like sudo: x:27:myusername
Otherwise, We use usermod to add an user to the sudoer group
usermod -aG sudo myusername
Finally you can check with this command :
sudo grep -E ‘%sudo|%wheel’ /etc/sudoers
You’ll have something like
%wheel ALL=(ALL) ALL
If you see a # at the first position, the line is commented, run sudo visudo, find the corresponding line and remove the #, save and check again.
Update your Ubuntu distro
sudo apt update && sudo apt upgrade
Remove Residue from previous docker installations
sudo apt remove docker docker-engine docker.io containerd runc
Debian/Ubuntu package repository configuration
source /etc/os-release
Trust the repo :
curl -fsSL https://download.docker.com/linux/${ID}/gpg | sudo apt-key add —
Update repo info :
echo «deb [arch=amd64] https://download.docker.com/linux/${ID} ${VERSION_CODENAME} stable» | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt update
Install official Docker release
sudo apt install docker-ce docker-ce-cli containerd.io
Add user to docker group
sudo usermod -aG docker $USER
«Then close that WSL window, and launch WSL again. You should see docker when you run the command groups to list group memberships.»
Get IP address in WSL2
echo `ifconfig eth0 | grep -E «([0-9]{1,3}.){3}[0-9]{1,3}» | grep -v 127.0.0.1 | awk ‘{ print $2 }’ | cut -f2 -d:
`
You should have something like 172.20.5.64
Launch dockerd
In WSL, there is no systemd or other init system. So we need to launch manually docker with the automatic collect of the IP address
sudo dockerd -H `ifconfig eth0 | grep -E «([0-9]{1,3}.){3}[0-9]{1,3}» | grep -v 127.0.0.1 | awk ‘{ print $2 }’ | cut -f2 -d:
`
There should be several lines of info, warnings related to tls, and the like, with something like API listen on 172.20.5.64:2375 at the end. If so, you have success.
Test docker command
Get the IP address given with the line API listen and In another WSL terminal, you can test the following command :
docker -H 172.20.5.64 run —rm hello-world
You’ll get something like this :
Hello from Docker!
…
Installing Docker.exe on Windows
Stefan Scherer is maintaining the project docker-cli-builder on GitHub where we can download the docker.exe command in standalone :
- Download the exe
- Put it in the directory like c:\bin
- Add this directory in the path for executables : System Properties\Environement Variables\System Variables\Path
Check if docker is working
Once done, logout from your session and log again
In a windows terminal (Windows Power Shell) , launch :
docker —version
You would get something like :
Docker version 20.10.5, build 55c4c8896
Launch dockerd
Open a terminal in Wsl2, you execute
sudo dockerd -H `ifconfig eth0 | grep -E «([0-9]{1,3}.){3}[0-9]{1,3}» | grep -v 127.0.0.1 |awk ‘{ print $2 }’ | cut -f2 -d:
`
And you get the IP address, as described before
Test docker on Windows
In the Powershell windows of the terminal, you can run the following command
c:\bin\docker -H tcp://172.20.5.64 run —rm hello-world
And you would get :
Hello from Docker!
…
Great we have now docker in windows running with WSL2.
But let’s continue magic !
Configure VSCode to access to WSL2 docker
If you launch Visual Code and you select the docker extension, you’ll get error in the panel asking if docker is installed… Yes of course it’s installed but not configured to access to WSL2
To do so, click on the icon (?) on the top right of the section «Containers» and select «Edit settings…»
You’ll get around 56 settings and you search for «Docker:Host» where you put the line «tcp://172.20.5.64:2375» where you can replace the highlighted ip address by the one you got before
Once done, you come back to the panel and you click on «refresh» icon (top right of each sections) and you would get information from your dockerd running in WSL2
Making everything works without knowing IP
Now, how to run dockerd and docker without copy&paste IP address in command line nor VSCode.
In WSL2, it’s not possible to assign IP address but, I can use the windows port forwarding to redirect a local port from the host to a specific one of my distribution. Hence I could put «tcp://localhost:2375» in VsCode and the calls will be redirected to dockerd running in WSL2-Ubuntu.
For this, I run the powershell script lines in windows terminal running as administrator :
$ip = (wsl sh -c «hostname -I»).Split(» «)[0]
netsh interface portproxy add v4tov4 listenport=2375 connectport=2375 connectaddress=$ip
wsl sh -c «sudo dockerd -H tcp://$ip»
Script explanation :
- First, I collect the IP address of my default distro with the wsl command.
- Second, I set the port forwarding 2375 to my distro
- Third, I launch in my distro dockerd with the IP
When executing these lines you’ll be prompted to enter your distro password (sudo) and I’ll see after the log of dockerd. Everything will work fine when I’ll see the message «API listen on 172.18.75.23:2375».
In parallel, in a windows terminal opened in my distro, I can check with top or htop if dockerd processes are running.
In VSCode, I update my Docker:Host setting with tcp://localhost:2375 :
And the magic is there :
Now I can know create a dedicated powershell script with the previous line : start_docker.ps1
In a windows terminal running with administrator privileges, I set the Execution policy with :
Set-ExecutionPolicy RemoteSigned
And every time I want to run dockerd, I launch the start_docker.ps1 script:
And if you see API Listen on 172.18.75.23:2375
Everything works !
Now, I want to use docker without -H parameter, for this, I add a new system environment variable called DOCKER_HOST set to tcp://localhost:2375
Finally, in a windows terminal, I can simply run a command like this:
docker image ls
In conclusion
This article shows how we can use docker in windows and WSL2 without Docker Workstation
To do so, we just need first to run a powershell script launching dockerd in WSL2 and once dockerd is listening we can simply use the command docker (maintained by Stefan Scherer).
Yes ! We can continue to develop with containers without Docker Workstation.
Enjoy !
After installing docker on my Windows 10 machine, When I tried to open the docker desktop application encountered with You are not allowed to use Docker . You must be in the “docker-users” group error.
To resolve this issue, You need to add your user to docker-users named group created under Computer Management/user and groups/groups
Click on docker-users and add your username in the group.
Apply the changes and then you need to restart your windows to let the changes come in effect
Note: You can refer “Docker Deep Dive” book if you want to understand the underlying concept of Docker. Very well designed for beginners and people who are looking to enhance their knowledge. It can also help you crack the interviews for DevOps with Docker concepts
Published by codenamebazinga
Just Another Geek!
View all posts by codenamebazinga
Published