Giter VIP home page Giter VIP logo

devcontainer's Introduction

Run devcontainer outside of Visual Studio Code

Are you also a big fan of Visual Studio Devcontainer? Do you also sometimes want to just run the devcontainer outside of Visual Studio Code? Me also! That is why I have created this simple bash script. The script parses the devcontainer.json file and runs the docker container outside of Visual Studio Code.

Example

Example

How does it work?

The script can be run in any workspace the contains the .devcontainer configuration folder. On start, it parses several different options from the devcontainer.json file, builds the dockerfile, and starts the container. The script mounts the current folder into the container into the /workspaces/$currentfolder path. Same as Visual Studio Code does.

The following options from the devcontainer.json are supported:

  • dockerFile uses the defined dockerfile.
  • settings["terminal.integrated.shell.linux"] uses the defined shell.
  • forwardPorts published the defined ports to the host.
  • remoteEnv uses the defined environment variables.
  • remoteUser starts the shell with the defined user.

How to install?

You can install the devcontainer script by either downloading the script and place it into a folder in you $PATH variable or you can use the following command to download and install the script.

sudo sh -c 'curl -s https://raw.githubusercontent.com/BorisWilhelms/devcontainer/main/devcontainer.sh > /usr/local/bin/devcontainer && chmod +x /usr/local/bin/devcontainer'

Prerequisites

The script uses jq to parse the devcontainer.json. Therefore it must be installed.

Known issues

  • Since jq expects a valid JSON file, all possible JSON error (e.g. , without following properties) has to be corrected. The script will strip all comments (//) to make it more valid.

devcontainer's People

Contributors

boriswilhelms avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

devcontainer's Issues

DevContainers without IDE

Hello!
This is not a bug, just got very curious. What do you use devcontainers for without an IDE? When and in what cases is it necessary?
Thanks in advance.

Issue with hyphens in build args used in FROM

Hi thanks for a great tool.

I'm taking the Dockerfile and devcontainer.json from here.

The ARG for setting the ${VARIANT} contains a dash which seems to create a problem with the passing of command-line args in this script.

Here is the error I get:

docker: invalid reference format: repository name must be lowercase.
See 'docker run --help'.

and the debug output is:

Using workspace -v
[DEBUG] CONFIG_DIR: ./.devcontainer
[DEBUG] CONFIG_FILE: devcontainer.json
[DEBUG] CONFIG: 
{
        "name": "Node.js",
        "build": {
                "dockerfile": "Dockerfile",
                "args": { "VARIANT": "16-bullseye" }
        },

        "customizations": {
                "vscode": {
                        "extensions": [
                                "dbaeumer.vscode-eslint"
                        ]
                }
        },



        "remoteUser": "node"
}
[DEBUG] DOCKER_FILE: /home/amo_chumber/scratch/devcontainer-test/.devcontainer/Dockerfile
[DEBUG] REMOTE_USER: node
[DEBUG] ARGS: --build-arg VARIANT="16-bullseye"
[DEBUG] SHELL: null
[DEBUG] PORTS: 
[DEBUG] ENVS: 
[DEBUG] WORK_DIR: /workspace
[DEBUG] MOUNT:  --mount type=bind,source=-v,target=/workspace
Building and starting container
invalid reference format
[DEBUG] DOCKER_IMAGE_HASH: Sending build context to Docker daemon  4.096kB
Step 1/2 : ARG VARIANT=16-bullseye
Step 2/2 : FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:${VARIANT}
docker: invalid reference format: repository name must be lowercase.
See 'docker run --help'.

I suspect this is a bash-ism with some quoting...

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.