Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Image to DockerfileNew to Visual Studio Code? Get it now.

Image to Dockerfile

Brigit

|
104 installs
| (0) | Free
Convert the "image" property in a devcontainer.json to a Dockerfile.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Dev container "image" to Dockerfile converter

This is a simple Visual Studio Code extension to convert the "image" property in a devcontainer.json to a Dockerfile.

Demo gif of converting "image" to a Dockerfile

A devcontainer.json is a structured JSON with Comments (jsonc) metadata format part of the Dev Container Specification. Tools can use it to store any needed configuration required to develop inside of local or cloud-based containerized coding.

Note: This extension supports your existing dev container configuration files and workflows. To actually create, build, and work within dev containers in VS Code, check out the Dev Containers extension, GitHub Codespaces, or the Dev Container Spec.

Running the extension

  • Clone the repo: git clone https://github.com/bamurtaugh/devcontainer-image-convert
  • Open the repo in VS Code (stable or insiders): code devcontainer-image-convert or code-insiders devcontainer-image-convert
  • Open VS Code terminal, run npm install
  • F5 to run the extension

Development status

This extension is under active development.

Items left to be investigated or implemented are designated with TODO in extension.ts. Here are the main ones:

  1. Better handle if Dockerfile already exists (rather than silently failing
    • Give option to cancel or overwrite, and overwrite will replace existing contents rather than write same FROM contents again
  2. Open the Dockerfile automatically after creation (or provide an extension setting to open Dockerfile automatically)

Code Action Provider Sample

This extension is based off the Visual Studio Code Code Action Provider sample extension, which shows how to provide code actions in the editor. Code actions are used to implement quick fixes and refactoring in VS Code.

Contributing

Please feel free to contribute changes to this extension via issues or PRs in this repo.

Further reading

  • Dev container specification
  • Guide to using images, Dockerfiles, and Docker Compose
  • Spec issue tracking presence of Dockerfiles in spec-provided Templates

License

The Code Action Provider sample has the following license:

  • Copyright (c) Microsoft Corporation. All rights reserved.
  • Licensed under the MIT License.

You can find the license for this extension in this repo's LICENSE.md.

  • Contact us
  • Jobs
  • Privacy
  • Terms of use
  • Trademarks
© 2023 Microsoft