Getting started with Docker and NixOS
Docker and Nix are available within CodeSandbox Repositories as an experimental feature. You can run and build images to run containers inside your project by opening a terminal and running
docker. If you have a
docker-compose file in your root folder, you only have to run
docker-compose up. Then, all your services will run within CodeSandbox Repositories.
In addition, Nix is also supported. Nix is a tool that takes a unique approach to package management and system configuration. Basically, you can install any additional tool, like Java or Node v16, in your OS.
If you run a development server (for example inside the container) and it opens up a port, then CodeSandbox Repositories will detect that automatically and make the preview available. In this case, you can open the preview from the Other Previews submenu.
If you would like to start a given container every time you create a new branch or even restart your repositories, then you can persist it as a task, as shown below.
Simply paste the command into the Command Palette and CodeSandbox Repositories will create a configuration file.
If you define this as a task, you will be able to run the container from the UI. You can also put it under
setupTask - in this case, the container will start the next time you create a workspace.
Tip: Commit your changes and add the configuration to your repository so CodeSandbox can run the container for every newly created branch.