-
-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Cannot locate specified Dockerfile when using FromDockerfile #763
Comments
Hi @L3AZH I'm able to reproduce the error you describe in this issue, but I think it's not caused by the library itself: in the ZIP file provided above, the Dockerfile lives in a directory with no access to the If from the cmd/httpserver dir you run I'd suggest trying a structured format that allows building the image. |
Hi @mdelapenya,
I'm able to run My
My package main_test
import (
"context"
"go-specs-greet/go_specs_greet"
"go-specs-greet/specifications"
"log"
"os/exec"
"testing"
"github.com/alecthomas/assert/v2"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/wait"
)
func TestGreeterServer(t *testing.T) {
ctx := context.Background()
cmd := exec.Command("pwd")
stdout, err := cmd.Output()
if err != nil {
log.Fatalln(err)
}
path := string(stdout)
log.Println(path)
req := testcontainers.ContainerRequest {
FromDockerfile: testcontainers.FromDockerfile{
Context: "../../.",
Dockerfile: "Dockerfile",
PrintBuildLog: true,
},
ExposedPorts: []string{"8080:8080"},
WaitingFor: wait.ForHTTP("/").WithPort("8080"),
}
log.Println(req.FromDockerfile.Context)
log.Println(req.FromDockerfile.Dockerfile)
container, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
ContainerRequest: req,
Started: true,
})
assert.NoError(t, err)
t.Cleanup(func() {
assert.NoError(t, container.Terminate(ctx))
})
driver := go_specs_greet.Driver{BaseURL: "http://localhost:8080"}
specifications.GreetSpecification(t, driver)
} |
Simply downloading your ZIP file and running the tests I get this:
So it seems to build the Docker image but the assertions fail. |
So I just do the same as you, |
Mmm, so it happens on a Windows machine? Let me check on that platform, but it will be next Monday 🙏 I'm reopening the issue just until we confirm it's not a Windows issue |
@L3AZH good news! We discovered a weird behaviour in how Docker handles absolute Vs relative paths when tarring string representations for paths on Windows. We have fixed it in #814, always passing the absolute path to Docker. On other hand, we had a hard time understanding the layout of the project, as it's not very common to see the Dockerfile copying files from In any case, thanks for reaching out with this issue, it helped us to trigger an internal discussion on how Docker works under the hood. Cheers! |
Hi @mdelapeny, it’s good to know that, thank you for supporting me with the problem 👍 |
Testcontainers version
0.17.0
Using the latest Testcontainers version?
Yes
Host OS
Windows
Host arch
x64
Go version
1.19.4
Docker version
Docker info
What happened?
Describe the bug
I'm creating a go-service with testcontainer by using
FromDockerfile
in a test function, but when I run a test, it could not locate the dockerfileI already run the test function
go func Test_BuildContainerFromDockerfile(t *testing.T)
in file docker_test.go (in the testcontainer src) but the result still the same as my testMy Test function
The output of my test
The test function
go func Test_BuildContainerFromDockerfile(t *testing.T)
indocker_test.go
The output when I run a test function in
docker_test.go
Relevant log output
No response
Additional information
This is my project
Scaling acceptance tests.zip
The text was updated successfully, but these errors were encountered: