testcontainers / testcontainers/testcontainers-dotnet

[Enhancement]: Dockerfile with inline scripts

Open
#1,247 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

buildkit enhancement
Dominant language
C#
Stars
4.4k
Forks
357
Avg merge
14h 42m
Merged PRs (30d)
16

Description

Testcontainers version

3.9.0

Using the latest Testcontainers version?

Yes

Host OS

Windows 11

Host arch

x86

.NET version

8.0.108

Docker version
Client:
 Version:           27.2.0
 API version:       1.45 (downgraded from 1.47)
 Go version:        go1.21.13
 Git commit:        3ab4256
 Built:             Tue Aug 27 14:17:17 2024
 OS/Arch:           windows/amd64
 Context:           default

Server:
 Engine:
  Version:          26.1.3
  API version:      1.45 (minimum version 1.24)
  Go version:       go1.22.5
  Git commit:       8e96db1c328d0467b015768e42a62c0f834970bb
  Built:            Sun Jul  7 17:34:20 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.7.17
  GitCommit:        3a4de459a68952ffb703bbe7f2290861a75b6b67
 runc:
  Version:          1.1.12
  GitCommit:        51d5e94601ceffbbd85688df1c928ecccbfa4685
 docker-init:
  Version:          0.19.0
  GitCommit:
Docker info
Client:
 Version:    27.2.0
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.10.4
    Path:     C:\Users\<redacted>\.docker\cli-plugins\docker-buildx.exe
  compose: Docker Compose (Docker Inc.)
    Version:  v2.29.2
    Path:     C:\Users\<redacted>\.docker\cli-plugins\docker-compose.exe

Server:
 Containers: 6
  Running: 1
  Paused: 0
  Stopped: 5
 Images: 52
 Server Version: 26.1.3
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 3a4de459a68952ffb703bbe7f2290861a75b6b67
 runc version: 51d5e94601ceffbbd85688df1c928ecccbfa4685
 init version:
 Security Options:
  seccomp
   Profile: builtin
 Kernel Version: 5.10.102.1-microsoft-standard-WSL2
 Operating System: Rancher Desktop WSL Distribution
 OSType: linux
 Architecture: x86_64
 CPUs: 24
 Total Memory: 15.47GiB
 Name: G9WG5S3
 ID: aa23d5ea-e978-4661-a673-02dd7790e5e8
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
What happened?

Dockerfiles with inline bash scripts don't build properly. I'll be changing line 7 of the Dockerfile for these examples in the repo listed below. For all these instances, I verified that docker-compose could spin up the Dockerfile before trying it with TestContainers.

If the docker file contains COPY <<-"EOF" start.sh, testcontainers is throwing COPY failed: no source files were specified.

I've tried converting the COPY command into a run command, which gets me a bit further. The image builds, but it never starts. Using RUN cat <<"EOF" > start.sh yields, System.TimeoutException: The operation has timed out.

I can work around the issue by moving the inline script into its own bash file and pulling it into the Dockerfile instead.

Relevant log output
COPY failed: no source files were specified

OR 

System.TimeoutException: The operation has timed out
Additional information

https://github.com/Steven-Harris/testcontainers-inline-script-issue

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked testcontainers-inline-script-issue reproduction and its Dockerfile, especially line 7, then compare the Docker Compose behavior with the Testcontainers build and startup path. Reproduce both the heredoc COPY failure and the RUN-generated script timeout; done means inline scripts build and the resulting container starts successfully through Testcontainers.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, csharp, docker
Domain
devops, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.