Giter VIP home page Giter VIP logo

dexec's Introduction

dexec Build Status Download

A command line utility for executing code in many different languages using the Docker Exec images, written in Go.

dexec demo animation

Installation

Using Bintray

Download the appropriate binary for your OS and architecture, then unzip or untar and move the dexec executable to where it can be found on your PATH.

OS 64-bit 32-bit
Linux 64-bit 32-bit
Mac 64-bit 32-bit
Windows 64-bit 32-bit

Binaries for other distributions are available on Bintray.

Using Go

If you have Go installed and configured correctly, you can install dexec with the go get command.

$ go get github.com/docker-exec/dexec

Reference

These examples use a .cpp source file, but any of the supported languages can be used instead. Arguments can be passed in any order, using any style of the acceptable switch styles described.

The application provides help and version information as follows:

$ dexec --version
$ dexec --help

Pass source files to execute

Multiple source files can be passed to the compiler or interpreter as follows. The first source file's extension is used to pick the appropriate Docker Exec image, e.g. .cpp retrieves dexec/cpp from the Docker registry.

$ dexec foo.cpp
$ dexec foo.cpp bar.cpp

The sources are mounted individually using the default Docker mount permissions (rw) and can be specified by appending :ro or :rw to the source file.

Pass individual arguments for build

For compiled languages, arguments can be passed to the compiler.

$ dexec foo.cpp --build-arg=-std=c++11
$ dexec foo.cpp --build-arg -std=c++11
$ dexec foo.cpp -b -std=c++11

Pass arguments for execution

Arguments can be passed to the executing code. Enclose arguments with single quotes to preserve whitespace.

$ dexec foo.cpp --arg=hello --arg=world --arg='hello world'
$ dexec foo.cpp --arg hello --arg world --arg 'hello world'
$ dexec foo.cpp -a hello -a world -a 'hello world'

Specify location of source files

By default, dexec assumes the sources are in the directory from which it is being invoked from. It is possible to override the working directory by passing the -C flag.

$ dexec -C /path/to/sources foo.cpp bar.cpp

Include files and folders mounted in Docker container

Individual files can be mounted without being passed to the compiler, for example header files in C & C++, or input files for program execution. These can be included in the following way.

$ dexec foo.cpp --include=bar.hpp
$ dexec foo.cpp --include bar.hpp
$ dexec foo.cpp -i bar.hpp

In addition, a program may require read and/or write access to several files on the host system. The most efficient way to achieve this is to include a directory.

$ dexec foo.cpp --include=.
$ dexec foo.cpp --include .
$ dexec foo.cpp -i .

Files and directories are relative to either the current working directory, or the directory specified with the -C flag.

As with sources, included files and directories are mounted using the default Docker mount permissions (rw) and can be specified by appending :ro or :rw to the source file.

Force dexec to pull latest version of image

Primarily for debugging purposes, the --update command triggers a docker pull of the target image before executing the code.

$ dexec foo.cpp -u
$ dexec foo.cpp --update

Make executable source with shebang

dexec can be used to make source code executable by adding a shebang that invokes it at the top of a source file.

The shebang is stripped out at execution time but the original source containing the shebang preserved.

#!/usr/bin/env dexec
#include <iostream>
int main() {
    std::cout << "hello world" << std::endl;
}

then

$ chmod +x foo.cpp
$ ./foo.cpp

See also

dexec's People

Contributors

andystanton avatar docker-exec-bot avatar inthecloud247 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.