Docksal: Misleading error with path access when not logged into docker

By berliner, 10 May, 2022

tl;dr
If you see the error The path is not accessible in Docker when running $ fin up to get a docksal based project to run, it might be worth confirming that you are logged into docker.com by running $ docker login.

Full story
I just spend an hour debugging an alleged file permissions issue on a new linux box that I setup to run tests for my Drupal projects. I use docksal and received this error when trying to run fin up:

The path is not accessible in Docker
Could not access /PATH/TO/MY/PROJECT
It is not shared from your host to Docker or is restricted.

So that set me off onto an unsuccessful hunt for how to share directories on linux. I normally work on Apple machines, so I wasn't sure how exactly that was supposed to work. My searches on the internet seemed to indicate that I was the only single person in the world having that problem on a linux machine (hence this blog post now).

Short of abandoning this task and doing something else, I had a closer look at the code that was responsible for showing that message:

# Checks if path is accessible to Docker (takes 1.2s on average)
# @param $1 - path to check (fails if empty)
is_docker_path ()
{
	local _path="${1}"
	[[ "$_path" == "" ]] && return 1
	(cd "$_path" 2>/dev/null && docker run --rm -v "$_path":"$_path" busybox 2>/dev/null)
}

Only once I tried to run that busybox image myself on the command line did I realise I wasn't logged in to docker. So my problem wasn't that there was anything odd with my permissions, but a completely different problem that docksal just didn't check for.

So a simple $ docker login fixed the problem for me.

Hope this helps someone else out there.

Tags