This question, as others have also pointed out, is irrelevant. The process of adding a user to the docker
group is only necessary on Linux where sudo
privileges are required to run Docker commands, as explained here. On macOS, and using docker-machine
, that is unnecessary.
But if one wants to add a user, or more specifically the current user, to the docker
user group, for whatever reason, here are the instructions:
- List the existing user groups with
dscl . list /groups
from here
- To create a user group, if it doesn't exist use the command
sudo dscl . create /Groups/<groupName>
from here.
- In the context of this discussion the
<groupName>
could be replaced with docker
.
- To add a user to a group one can use the command
sudo dseditgroup -o edit -a <userName> -t user <groupName>
. from here or sudo dscl . append /Groups/<groupName> GroupMembership <userName>
from here.
- One can replace the
<userName>
with $USER
or $(whoami)
to refer to the current user.
- To test and see if the expected user has been added o the specific group one can use the command
dscl . -read /Groups/<groupName> GroupMembership
to list all the remembers. However, it is not guaranteed to deliver the correct result, as explained here.
And the another issue with the Visual Studio Code, also has barely anything to do with the user groups. By running the eval "$(docker-machine env <dockerMachineName>)"
in a new terminal, and running the code
editor from inside the terminal, the Docker extension works just fine.