testcontainers-go
testcontainers-go copied to clipboard
Using FromDockerfile causing Runtime error
Describe the bug
I'm testing ElasticSearch and need to load some plugins before the process starts. So I've decided to build it from Dockerfile When I switch configuration from Image
to FromDockerfile
it fails.
To Reproduce
import (
t "github.com/testcontainers/testcontainers-go"
)
elasticsearchContainerRequest := t.ContainerRequest{
FromDockerfile: t.FromDockerfile{
Context: "./testcontainers",
Dockerfile: "elasticsearch.Dockerfile",
},
}
elasticsearchContainer, err := t.GenericContainer(ctx, t.GenericContainerRequest{
ContainerRequest: elasticsearchContainerRequest,
Started: true,
})
defer elasticsearchContainer.Terminate(ctx)
Output
Test Panicked
In [It] at: /opt/homebrew/Cellar/go/1.18.3/libexec/src/runtime/panic.go:220
runtime error: invalid memory address or nil pointer dereference
Full Stack Trace
command-line-arguments_test.glob..func1.2.1.1()
/search_suite_test.go:65 +0x300
// search_suite_test.go:65
defer elasticsearchContainer.Terminate(ctx)
Expected behavior It should build an image from a Dockerfile I provided
** docker info **
$ docker info
Client:
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc., v0.8.2)
compose: Docker Compose (Docker Inc., v2.6.1)
extension: Manages Docker extensions (Docker Inc., v0.2.7)
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
scan: Docker Scan (Docker Inc., v0.17.0)
Server:
Containers: 3
Running: 2
Paused: 0
Stopped: 1
Images: 10
Server Version: 20.10.17
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc io.containerd.runc.v2 io.containerd.runtime.v1.linux
Default Runtime: runc
Init Binary: docker-init
containerd version: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
runc version: v1.1.2-0-ga916309
init version: de40ad0
Security Options:
seccomp
Profile: default
cgroupns
Kernel Version: 5.10.104-linuxkit
Operating System: Docker Desktop
OSType: linux
Architecture: aarch64
CPUs: 8
Total Memory: 7.764GiB
Name: docker-desktop
ID: RL34:ZU2T:AV7X:3YUR:73R6:RW4O:EYW4:KAZB:MZHC:QPYR:Q7HN:FQLL
Docker Root Dir: /var/lib/docker
Debug Mode: false
HTTP Proxy: http.docker.internal:3128
HTTPS Proxy: http.docker.internal:3128
No Proxy: hubproxy.docker.internal
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
hubproxy.docker.internal:5000
127.0.0.0/8
Live Restore Enabled: false
Additional context This is my Dockerfile
FROM docker.elastic.co/elasticsearch/elasticsearch:7.16.2
COPY ./analysis-icu-7.8.0.zip /tmp/analysis-icu-7.8.0.zip
COPY ./hunspell.zip /tmp/hunspell.zip
RUN unzip /tmp/hunspell.zip -d /usr/share/elasticsearch/config
RUN elasticsearch-plugin install file:///tmp/analysis-icu-7.8.0.zip
Hi @nikneroz could you please share your ZIP files so that we can test this with the same inputs?
Thanks!
Apart from that, I've used the build-from-dockerfile feature with sucess very recently, using a similar use case that the one you present here. Please take a look at this: https://github.com/gAmUssA/testcontainers-go-kong/pull/5, more specifically here: https://github.com/gAmUssA/testcontainers-go-kong/pull/5/files#diff-f91d8da8d2500d961843fd0de981ab582130f718af01d224d582a7c8baa9ffc3R22
@nikneroz I'm closing as it has been stale for a long time after sharing my comments, but feel free to reopen it in the case you need more from us here.
Thanks!