Skip to content

socktainer/sample-testcontainers-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚢🍏 Testcontainers with Socktainer Sample

This project demonstrates how to use Testcontainers with Socktainer, which provides a socket interface on top of Apple container.

⚙️ Socktainer Configuration

Socktainer must be configured to expose a socket that Testcontainers can use instead of the Docker socket.

🔧 Configure Socket Usage for TestContainers

Following the Testcontainers Docker host configuration, configure the Docker host to use Socktainer:

1. Environment Variable (recommended):

export DOCKER_HOST=unix://$HOME/.socktainer/container.sock

2. System Property:

-Ddocker.host=unix://$HOME/.socktainer/container.sock

3. Testcontainers Configuration File (~/.testcontainers.properties):

docker.host=unix://$HOME/.socktainer/container.sock

Note: Replace $HOME with the actual path in the properties file.

⚠️ Disable Ryuk Container

The Ryuk container expects to mount some Docker socket in containers. For now, this is not supported in Socktainer mode.

Use the environment variable TESTCONTAINERS_RYUK_DISABLED=true when running Maven:

TESTCONTAINERS_RYUK_DISABLED=true mvn install

🚀 Running the Sample

📋 Prerequisites

  • ☕ Java 23 or higher
  • 📦 Maven 3.9 or higher
  • 🔌 Socktainer running with socket exposed (run ./socktainer)

🏃‍♂️ Start Socktainer

Assuming Socktainer is not running, start it now:

./socktainer
[ NOTICE ] Server started on http+unix: $HOME/.socktainer/container.sock

🧪 Run Tests with Ryuk Disabled

TESTCONTAINERS_RYUK_DISABLED=true mvn test

About

Example showcasing the usage of socktainer and testcontainers

Topics

Resources

License

Stars

Watchers

Forks

Languages