I am executing this test case inside a container as the golang:1.7 is not available on my host machine. I created a container and start it in bash mode and followed the steps mentioned in the link https://tdeheurles.github.io/acting-on-docker-from-inside-docker/
And here is the problem I am facing, when I am trying to build a docker image , it is showing following error always
Error response from daemon: Cannot locate specified Dockerfile: Dockerfile
Here is the my Dockerfile content
FROM golang:1.9
I created this Dockerfile just for testing to make sure I can able to creating the image with the golang program.
Here is my goLang logic
dockerFile := "Dockerfile"
imageName := "test_build_image"
ctx := context.Background()
cli, err := client.NewEnvClient()
buildOptions := types.ImageBuildOptions{ Tags: []string{imageName}, Dockerfile: dockerFile }
buildResponse, err := cli.ImageBuild(ctx,dockerBuildContext, buildOptions)
EDIT:1
Strangely this piece of code is working
cli, _ := client.NewEnvClient()
dockerBuildContext, err := os.Open("anil_test.tar")
defer dockerBuildContext.Close()
buildOptions := types.ImageBuildOptions{Tags: []string{"my_image"}, Dockerfile: "Dockerfile"}
buildResponse, err := cli.ImageBuild(context.Background(), dockerBuildContext, buildOptions)
When I am using same piece of code by passing my Dockerfile as an argument to the os.Open("Dockerfile") it is not working .Does it mean we need to pass only .tar file of Docker ??