skip to Main Content

Probably because an update, but I don’t know why, my Makefiles cannot execute docker now.
Do you have any idea?

➤  cat Makefile 
dock:
    docker ps
php:
    php -v
➤  make dock  
docker ps
make: docker: Permission denied
make: *** [Makefile:2: dock] Error 127
➤  make php                                                               2 ↵
php -v
PHP 7.4.28 (cli) (built: Feb 17 2022 16:17:19) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.28, Copyright (c), by Zend Technologies
➤  docker ps
CONTAINER ID   IMAGE                  COMMAND                  CREATED      STATUS         PORTS                                       NAMES
9c1ff6f5e0dc   postgres:14.2-alpine   "docker-entrypoint.s…"   9 days ago   Up 4 minutes   0.0.0.0:5434->5432/tcp, :::5434->5432/tcp   digital-docker-c-postgres-1

Thanks in advance

3

Answers


  1. You probably have a directory name docker on your PATH. There’s a bug in the current versions of GNU make (actually, it’s a bug in gnulib) where it doesn’t skip subdirectories of directories on the PATH.

    You can either remove the docker subdirectory, or force make to invoke a shell to run your command, maybe like this:

    dock:
            docker ps ;
    
    Login or Signup to reply.
  2. I recently encountered same issue as this, with the same permission denied error message while using docker and gmake with Golang.

    In my case, the issue was caused by excluding the main package in my build command, thereby producing a binary that doesn’t have an entry point.

    To elucidate, I had my directory like so: cmd/app and cmd/api.go. api.go contains my main function in the main package. My build command was go build -o tmp/bin/binary-name ./cmd/app*.go, which will build the binary based on go files found only in app package. Then I got the error when attempting to run the produced binary file.

    I rectified by changing my build command to include the main package like so: go build -o tmp/bin/binary-name ./cmd/*.go

    Login or Signup to reply.
  3. For my Env: Ubuntu 22.10, GNU Make 4.3

    I have Makefile:

    test:
        docker ps -a
    

    I use command make test --debug and have Error:

    GNU Make 4.3
    Built for x86_64-pc-linux-gnu
    Copyright (C) 1988-2020 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    Reading makefiles...
    Updating makefiles....
    Updating goal targets....
     File 'test' does not exist.
    Must remake target 'test'.
    docker ps -a
    make: docker: Permission denied
    make: *** [Makefile:19: test] Error 127
    

    Solution: You need downgrade GNU Make to 4.2 (more details)

    Total:

    GNU Make 4.2.1
    Built for x86_64-pc-linux-gnu
    Copyright (C) 1988-2016 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    Reading makefiles...
    Updating makefiles....
    Updating goal targets....
     File 'test' does not exist.
    Must remake target 'test'.
    docker ps -a
    CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
    Successfully remade target file 'test'.
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search