ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Docker /usr/local/Homebrew is not writable, Cannot connect to the Docker daemon 문제 해결
    네트워크 & 인프라 2024. 6. 4. 22:39

     

    /usr/local/Homebrew is not writable 문제 발생 

     

    만약 brew upgrade docker 명령어를 실행할 때, 다음과 같이 /usr/local/Homebrew is not writable문제가 발생한다면, 

    Error: /usr/local/Homebrew is not writable. You should change the
    ownership and permissions of /usr/local/Homebrew back to your
    user account:
      sudo chown -R user /usr/local/Homebrew
    ==> Downloading https://formulae.brew.sh/api/formula.jws.json
    ######################################################################################################################## 100.0%
    ==> Downloading https://formulae.brew.sh/api/cask.jws.json
    ######################################################################################################################## 100.0%
    ==> Downloading https://formulae.brew.sh/api/cask_tap_migrations.jws.json
    ######################################################################################################################## 100.0%
    Warning: Treating docker as a formula. For the cask, use homebrew/cask/docker
    Error: The following directories are not writable by your user:
    ...
    
    You should change the ownership of these directories to your user.
      sudo chown -R user /usr/local/Homebrew /usr/local/etc/bash_completion.d /usr/local/lib/pkgconfig /usr/local/lib/python3.7/site-packages /usr/local/share/aclocal /usr/local/share/doc /usr/local/share/info /usr/local/share/locale /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7 /usr/local/share/man/man8 /usr/local/var/homebrew/locks /usr/local/var/log
    
    And make sure that your user has write permission.
      chmod u+w /usr/local/Homebrew /usr/local/etc/bash_completion.d /usr/local/lib/pkgconfig /usr/local/lib/python3.7/site-packages /usr/local/share/aclocal /usr/local/share/doc /usr/local/share/info /usr/local/share/locale /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7 /usr/local/share/man/man8 /usr/local/var/homebrew/locks /usr/local/var/log

     

    주어진 메세지에 따라 다음과 같이 권한을 부여해준다. 

     

    %   sudo chown -R user /usr/local/Homebrew /usr/local/etc/bash_completion.d /usr/local/lib/pkgconfig /usr/local/lib/python3.7/site-packages /usr/local/share/aclocal /usr/local/share/doc /usr/local/share/info /usr/local/share/locale /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7 /usr/local/share/man/man8 /usr/local/var/homebrew/locks /usr/local/var/log
    Password:
    %   chmod u+w /usr/local/Homebrew /usr/local/etc/bash_completion.d /usr/local/lib/pkgconfig /usr/local/lib/python3.7/site-packages /usr/local/share/aclocal /usr/local/share/doc /usr/local/share/info /usr/local/share/locale /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7 /usr/local/share/man/man8 /usr/local/var/homebrew/locks /usr/local/var/log

     

     

     

     

    Cannot connect to the Docker daemon at unix:///var/run/docker.sock

     

    docker 명령어 실행시에 다음과 같이 docker의 설치파일 충돌로 Cannot connect to the Docker daemon  문제가 발생했다. 

    % docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=1234 --name mysql mysql 
    
    docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
    See 'docker run --help'.

     

     

    나의 케이스의 경우 이전에 docker를 home brew로 설치하지 않아, brew연결이 되어있지 않았기 때문에 기존 docker를 삭제하고 재설치 하는 방법을 선택했다. 

     

    # docker가 연결되어 있지 않음 확인 
    % brew link docker
    Error: No such keg: /usr/local/Cellar/docker
    
    # 기존 docker 위치 확인 
    % which node
    /Users/user/.nvm/versions/node/v16.1.0/bin/node
    % which docker
    /usr/local/bin/docker
    
    # 기존 docker 삭제 
    % sudo rm -rf /usr/local/bin/docker
    
    # brew로 docker 재설치 
    % brew install --cask docker

     

Designed by Tistory.