Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am i forced to run docker with sudo on OS X?

Tags:

docker

macos

I'm trying to install docker on macOS 10.12.1

I had an older version of docker which i removed from the system.

• I've decided to use the Docker for Mac Environment and leverage hyperkit

• I do not have any existing containers that im working with

• I've done a clean install of the Native mac app, and the setting show its running correctly

Problems: Running docker ps as a standard user fails

➜ docker ps
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

success:

➜ sudo docker ps
Password:
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Question:

How do i prevent having to run with root privileges?

Additional Info

➜  bin ls -all | grep docker
lrwxr-xr-x    1 jmurphy  staff      67 Oct 29 21:43 docker -> /Users/jmurphy/Library/Group Containers/group.com.docker/bin/docker
lrwxr-xr-x    1 jmurphy  staff      75 Oct 29 21:43 docker-compose -> /Users/jmurphy/Library/Group Containers/group.com.docker/bin/docker-compose
lrwxr-xr-x    1 jmurphy  staff      75 Oct 29 21:43 docker-machine -> /Users/jmurphy/Library/Group Containers/group.com.docker/bin/docker-machine
lrwxr-xr-x    1 jmurphy  admin      75 Oct 29 20:50 docker-machine-driver-xhyve -> ../Cellar/docker-machine-driver-xhyve/0.2.3/bin/docker-machine-driver-xhyve
lrwxr-xr-x    1 jmurphy  staff      67 Oct 29 21:43 notary -> /Users/jmurphy/Library/Group Containers/group.com.docker/bin/notary


➜  bin ps aux | grep docker
jmurphy            815   0.5  1.2  4742256 103108   ??  S     9:43PM   0:22.64 /Applications/Docker.app/Contents/MacOS/com.docker.hyperkit -A -m 2G -c 2 -u -s 0:0,hostbridge -s 31,lpc -s 2:0,virtio-vpnkit,uuid=58fa3bf4-bc44-4df1-b637-b459084abef7,path=/Users/jmurphy/Library/Containers/com.docker.docker/Data/s50,macfile=/Users/jmurphy/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/mac.0 -s 3,virtio-blk,file:///Users/jmurphy/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2,format=qcow -s 4,virtio-9p,path=/Users/jmurphy/Library/Containers/com.docker.docker/Data/s40,tag=db -s 5,virtio-rnd -s 6,virtio-9p,path=/Users/jmurphy/Library/Containers/com.docker.docker/Data/s51,tag=port -s 7,virtio-sock,guest_cid=3,path=/Users/jmurphy/Library/Containers/com.docker.docker/Data,guest_forwards=2376;1525 -l com1,autopty=/Users/jmurphy/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty,log=/Users/jmurphy/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/console-ring -f kexec,/Applications/Docker.app/Contents/Resources/moby/vmlinuz64,/Applications/Docker.app/Contents/Resources/moby/initrd.img,earlyprintk=serial console=ttyS0 com.docker.driver="com.docker.driver.amd64-linux", com.docker.database="com.docker.driver.amd64-linux" ntp=gateway mobyplatform=mac -F /Users/jmurphy/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/hypervisor.pid
jmurphy            776   0.0  0.1 556636936   7780   ??  S     9:43PM   0:00.03 /Applications/Docker.app/Contents/MacOS/com.docker.driver.amd64-linux -db /Users/jmurphy/Library/Containers/com.docker.docker/Data/s40 -osxfs-volume /Users/jmurphy/Library/Containers/com.docker.docker/Data/s30 -slirp /Users/jmurphy/Library/Containers/com.docker.docker/Data/s50 -vmnet /var/tmp/com.docker.vmnetd.socket -port /Users/jmurphy/Library/Containers/com.docker.docker/Data/s51 -vsock /Users/jmurphy/Library/Containers/com.docker.docker/Data -docker /Users/jmurphy/Library/Containers/com.docker.docker/Data/s60 -addr fd:3 -debug
jmurphy            773   0.0  0.0 556622812   4068   ??  S     9:43PM   0:00.09 /Applications/Docker.app/Contents/MacOS/com.docker.osx.hyperkit.linux
jmurphy            772   0.0  0.1 556677904  11868   ??  Ss    9:43PM   0:00.27 com.docker.driver.amd64-linux -db /Users/jmurphy/Library/Containers/com.docker.docker/Data/s40 -osxfs-volume /Users/jmurphy/Library/Containers/com.docker.docker/Data/s30 -slirp /Users/jmurphy/Library/Containers/com.docker.docker/Data/s50 -vmnet /var/tmp/com.docker.vmnetd.socket -port /Users/jmurphy/Library/Containers/com.docker.docker/Data/s51 -vsock /Users/jmurphy/Library/Containers/com.docker.docker/Data -docker /Users/jmurphy/Library/Containers/com.docker.docker/Data/s60 -addr fd:3 -debug
jmurphy            771   0.0  0.1 556627968   9128   ??  Ss    9:43PM   0:00.54 com.docker.osx.hyperkit.linux
jmurphy            770   0.0  0.1  2513388  11132   ??  Ss    9:43PM   0:00.21 com.docker.slirp --db /Users/jmurphy/Library/Containers/com.docker.docker/Data/s40 --ethernet fd:3 --port fd:4 --vsock-path /Users/jmurphy/Library/Containers/com.docker.docker/Data/@connect --max-connections 900
jmurphy            769   0.0  0.2  2476848  12716   ??  Ss    9:43PM   0:00.45 com.docker.osxfs --address fd:3 --connect /Users/jmurphy/Library/Containers/com.docker.docker/Data/@connect --control fd:4 --volume-control fd:5 --database /Users/jmurphy/Library/Containers/com.docker.docker/Data/s40
jmurphy            768   0.0  0.1  2475860  12252   ??  Ss    9:43PM   0:01.61 com.docker.db --url fd:3 --git /Users/jmurphy/Library/Containers/com.docker.docker/Data/database
jmurphy            767   0.0  0.0 556622812   3980   ??  S     9:43PM   0:00.10 /Applications/Docker.app/Contents/MacOS/com.docker.osx.hyperkit.linux -watchdog fd:0
jmurphy            764   0.0  0.1 556679780   6492   ??  S     9:43PM   0:00.07 /Applications/Docker.app/Contents/MacOS/com.docker.osx.hyperkit.linux -watchdog fd:0
jmurphy           1887   0.0  0.0  2432804    840 s000  R+   10:18PM   0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn docker
root               100   0.0  0.0  2444416   1800   ??  Ss    9:43PM   0:00.01 /Library/PrivilegedHelperTools/com.docker.vmnetd
jmurphy           1878   0.0  0.0 556614264   3888   ??  S    10:17PM   0:00.01 /Applications/Docker.app/Contents/MacOS/com.docker.frontend {"action":"vmstateevent","args":{"vmstate":"running"}}
jmurphy           1877   0.0  0.0 556631812   4108   ??  S    10:17PM   0:00.01 /Applications/Docker.app/Contents/MacOS/com.docker.frontend {"action":"vmstateevent","args":{"vmstate":"running"}}

From The Docs: At installation time, Docker for Mac provisions an HyperKit VM based on Alpine Linux, running Docker Engine. It exposes the docker API on a socket in /var/tmp/docker.sock. Since this is the default location where docker will look if no environment variables are set, you can start using docker and docker-compose without setting any environment variables.

https://docs.docker.com/docker-for-mac/docker-toolbox/

like image 531
Jack Murphy Avatar asked Oct 30 '16 01:10

Jack Murphy


1 Answers

It seems the issue was caused by having legacies entires in my ~/.zshrc file.

To no success, I followed the steps where the instructions asked me to run:

 unset DOCKER_TLS_VERIFY
 unset DOCKER_CERT_PATH
 unset DOCKER_MACHINE_NAME
 unset DOCKER_HOST

However, if the entries in ~/.zshrc (possibly your ~/.bashrc) persist - you might need to manually remove them and restart your session - after that you should be able to run the command without needing sudo.

➜  ~ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
92176e251311        redis               "docker-entrypoint.sh"   9 hours ago         Up 9 hours          6379/tcp            composetest_redis_1
like image 64
Jack Murphy Avatar answered Sep 23 '22 18:09

Jack Murphy