Building Docker image on Raspberry Pi 3 with Ubuntu 16.04

Building Docker image on Raspberry Pi 3 with Ubuntu 16.04

When trying to build docker images using my raspberry pi 3, running Ubuntu Core 16.04, I kept getting following error:

error checking context: 'can't stat '/home/rajatjindal83/dockerfiles''.

My Dockerfile was pretty simple, so it was confusing what could be wrong.

FROM armhf/ubuntu
RUN apt-get update && apt-get -qy install git nano curl wget build-essential

I tried searching on Google, but couldn’t find anything that will fix this issue. When I couldn’t find any tried and tested solution, I started to think from a software engineering perspective of what could be causing this issue.

Apparently, Ubuntu Core use Snaps for installing packages, and by default Snaps cannot access ‘stuff’ they are not suppose to. and using same principle Docker (which is just another Snap package) didn’t had access to touch my home directory.

To fix this, I had to run following command:

snap connect docker:home core:home

References:
stack-over-flow
Snap Interfaces

Once I did this, I was able to successfully build my Docker image:

root@localhost:~/dockerfiles# docker build .
Sending build context to Docker daemon 2.048kB
Step 1/2 : FROM armhf/ubuntu ---> fa40ea71de37
Step 2/2 : RUN apt-get update && apt-get -qy install git nano curl wget build-essential --->
 Using cache ---> eef28b5573c8
Successfully built eef28b5573c8
root@localhost:~/dockerfiles#

Leave a Reply

Your email address will not be published. Required fields are marked *