Problem building first image

I am new to Docker and am experiencing a problem that I am unable to resolve. I have the current version of docker installed on Ubuntu 16. I’m trying to get a very basic container up and running with a custom image.

For the image I have a simple http server written in Go. This app is a single go file that uses only standard Go libraries. It launches a http server on port 8086 and when I browse to it it returns “hello from go”.

My directory structure is as follows


The contents of my DockerFile are:

FROM golang:1.8-alphine

COPY …/dockertest /dockertest

WORKDIR /dockertest

RUN go run servertest.go

To build the container I am issuing this command from inside the /opt/dockerimages/test working directory

docker build -t first_container .

and I continue to get back this error message

unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /opt/dockerimages/test/Dockerfile: no such file or directory

I’ve tried commenting out everything except FROM golang:1.8-alphine and I continue to get the same error message when attempting to build the image.


docker works with a client/server architecture.
So when you build your Docker Image with a docker build .... the current directory you are currently in is transfered to the docker daemon (which could run somewhere else, probably also in the cloud or in a swarm).
So when just the currently directory is copied to the daemon you should keep the content of the directory small, that the copy is fast and avoid COPY/ADD from somewhere else than your local directory.

1 Like