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