Search code examples
dockerbuildpackdocker-daemon

How do I grant the paketo builder access permissions to the docker socket when building from a docker image?


When using buildpacks to build my spring boot application on Fedora I get the following error during the execution of the spring-boot-plugin:build-image goal:

[INFO]     [creator]     ERROR: initializing analyzer: getting previous image: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/info": dial unix /var/run/docker.sock: connect: permission denied

After digging into the goal and buildpacks, I found the following command in the buildpack.io docs (by selecting "Linux" and "Container"):

docker run \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v $PWD:/workspace -w /workspace \
  buildpacksio/pack build <my-image> --builder <builder-image>

AFAICT this command should be equivalent to what happens inside of maven and it exhibits the same error. My previous assumption was that the use in the buildpacksio/pack image doesn't have the access permissions to my docker socket. (The socket had 660 permissions and root:docker owner).

UPDATE: Even after updating to 666 permissions the issue still persists.

I don't really want to allow anyone to interact with the docker socket so setting it to 666 seems unwise. Is this the only option or can I also add the user in the container to the docker group?


Solution

  • The solution was that the Fedora docker package is no longer the most up-to-date way to install Docker. See the official Docker documentation They both provide the same version number, but their build hash is different.

    While I could not fully diagnose the difference between the two, I can report that it works with docker-ce and doesn't with docker.