Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

make: docker: Permission denied

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

like image 902
Roukmoute Avatar asked Nov 16 '25 03:11

Roukmoute


2 Answers

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 ;
like image 58
MadScientist Avatar answered Nov 17 '25 18:11

MadScientist


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)

  • Link for download https://packages.debian.org/search?keywords=make
  • command for install sudo dpkg -i make*.deb

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'.
like image 41
Dmitry Rakovets Avatar answered Nov 17 '25 18:11

Dmitry Rakovets