12

I installed docker on Ubuntu with snap (snappy?), and then I ran this:

ln -sf /usr/bin/snap /usr/local/bin/docker

when I run docker build I get:

unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /var/lib/snapd/void/Dockerfile: no such file or

directory

  • Have a look at https://stackoverflow.com/questions/35511604/docker-unable-to-prepare-context-unable-to-evaluate-symlinks-in-dockerfile-pat – mattias Jun 12 '19 at 17:04

5 Answers5

19

I ran into this same problem. I was setting up an Ubuntu server and elected to have Docker installed during the initial setup. It installed using snap, and as a result I couldn't run Docker in any directory outside of my home directory. This includes trying to Docker run any program in /var/. I fixed it by doing sudo snap remove docker and reinstalled using the official instructions in the Ubuntu docs:

https://docs.docker.com/engine/install/ubuntu/

Winston Kotzan
  • 1,979
  • 20
  • 25
  • 2
    docker installed using the ubuntu server wizard at its installation, don't works. Your tip helped me. Thanks – JRichardsz Mar 03 '22 at 17:42
  • Why is it like this? 2023 and the snap docker install still has this issue. Is it broken for everyone, or just some people? – KernelDeimos Aug 26 '23 at 02:46
10

I've got the same error using Ubuntu, and I noticed that I had installed the wrong Docker. Instead of (docker - transitional package) install (docker.io - Linux container runtime)

apt install docker.io
dirbacke
  • 2,861
  • 21
  • 25
4

I got this exact error message when I was running in /tmp/foo. When I switched the directory to /home/me/tmp/foo, The error went away.

sjbrown
  • 562
  • 3
  • 5
  • I experienced the same issue here. I cloned a repository into `/opt/src` (Ubuntu 20.04). Since, I couldn't install Docker using the official methods, I tried `snap install docker` and it worked. I just want to confirm that running the `docker build .` in my home directotry DID work. – Bhoom Suktitipat Aug 16 '23 at 15:40
2

Run docker cmd by root privilege, you can simply do it by using sudo

Ali Faradjpour
  • 302
  • 6
  • 15
0

Uninstall snap docker version

snap remove docker

then restart and install again using apt / apt-get

apt-get install docker

this will install all symlinks related