runindock is a lightweight CLI tool that runs commands inside Docker containers, providing an easy way to execute simple language-specific tasks and web apps in isolated environments. It abstracts Docker commands, allowing you to run tools like Java, Go, Node.js, and more without directly using Docker commands.
- Docker-based environments: Execute commands inside isolated Docker containers without manually writing Docker commands.
- Language support: Easily run Go, Node.js, and more.
- Custom Docker images: Override default images with the
--rid:imageoption. - Cross-platform support: Works on Linux, macOS, and WSL.
- Download the
runindock.exefrom the Releases page. - Move the
.exetoC:\Windows\System32or any folder in yourPATH.
Alternatively, create a folder likeC:\runindockand add it to yourPATHby:- Right-click on This PC or My Computer, select Properties.
- Click on Advanced system settings > Environment Variables.
- Find the Path variable, select it, and click Edit.
- Add
C:\runindockand move your.exethere.
- Now, you can run the executable globally by typing
runindockin any command prompt or terminal.
- Download the
runindockbinary from the Releases page. - Move it to
/usr/local/bin/:sudo mv runindock /usr/local/bin/
- Make the binary executable:
sudo chmod +x /usr/local/bin/runindock
- Run the program from any terminal by typing
runindock.
Once installed, you can use runindock to execute commands inside Docker containers. Here are a few examples:
runindock go run main.go
runindock node app.js
By default, runindock uses lightweight Docker images like golang:alpine and node:alpine. You can override this by specifying a custom image with the --rid:image option.
runindock go run main.go --rid:image="golang:latest"
If your application needs to expose a specific port (e.g., when running a web server), you can use the --rid:port option to bind a port from the Docker container to your local machine.
runindock node app.js --rid:port=8080
In this example, the --rid:port=8080 option will map the container's port 8080 to your local machine, allowing you to access the application at localhost:8080.
For environments like Java, which use build tools like Maven or Gradle, you can specify the build tool with the --rid:tool option to ensure the correct environment is used inside the Docker container.
runindock java -jar app.jar --rid:tool=maven
In this example, the --rid:tool=maven option ensures that the application will be built and run using Maven inside the Docker container.
runindock <environment> <command> [--rid:image=<docker_image>] [--rid:port=<container_port>] [--rid:tool=<build_tool>] [--rid:framework=<framework>]
<environment>: The environment or programming language (e.g.,go,node).<command>: The command you want to run inside Docker (e.g.,run main.go).--rid:image: Optional. Specify a custom Docker image.--rid:port: Optional. Expose a port from the Docker container.--rid:tool: Optional. Specify a build tool (e.g.,maven,gradle) for environments that support it.--rid:framework: Optional. Specify a framework (e.g.,laravel,symfony) for languages that support it.rid: Stands for (runindock), is used to separate between potential conflicts (like--portin case of Laravel).
- Go: Run Go applications using the
goenvironment. - Node.js: Run Node.js applications or servers (e.g., Express) using the
nodeenvironment. - Java: Run Java applications or web apps/servers (e.g., Spring Boot) using the
javaenvironment. - Python: Run Python scripts or web applications (e.g., Django) using the
pythonenvironment. - Rust: Run Rust applications using the
rustenvironment. - PHP: Run PHP scripts and applications using the
phpenvironment.
More languages can be added by extending the tool.
runindock python script.py
Start by installing Django:
runindock pip install django
Then create a django project using:
runindock python -m django startproject myproject
Finally, run the application:
runindock python manage.py runserver
Start by compiling the java code using javac:
javac HelloWorld.java
Then you can now, run the compiled byte-code:
java HelloWorld.class
You can run a Spring Boot application directly using Maven:
runindock mvn spring-boot:run --rid:port=8080
Or package the application with Maven and run the generated JAR:
runindock mvn clean package
runindock java -jar target/spring-app-1.0-SNAPSHOT.jar --rid:port=8080 --rid:tool=maven
runindock npm init
runindock npm install express
runindock node index.js --rid:port=8080
To generate a Rust project:
runindock cargo new my-rust-project
First, compile your Rust program:
runindock cargo build
Then, run the compiled binary:
runindock cargo run
To execute a standalone PHP script:
runindock php script.php
After generating a project using:
runindock composer create-project symfony/skeleton my_project --rid:framework=symfony
You can run a simple PHP development server:
runindock php -S 0.0.0.0:8080 -t public/ --rid:port=8080
This serves files from the public/ directory.
If you're working with a Laravel application, you can serve it using the built-in Laravel development server:
runindock composer create-project laravel/laravel my-laravel-app --rid:framework=laravel
runindock php artisan serve --host=0.0.0.0 --port=8080 --rid:port=8080
Contributions are welcome! If you'd like to add support for more languages or features, follow these steps:
- Fork the project.
- Create a new branch for your feature.
- Make your changes and ensure all tests pass.
- Submit a pull request, explaining your changes.
Make sure to test your changes before submitting:
# Compile and test the project locally
g++ main.cpp -o runindock
./runindock go run main.go
This project is licensed under the MIT License - see the LICENSE file for details.
Special thanks to the open-source community for the inspiration and support!