Tutorial
Getting started with Docker and NixOS

Getting started with Docker and NixOS

As an experimental feature, Docker and Nix are available within Projects. 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 have to run only docker-compose up and that's all, all your services will run within Projects.

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.

1. Click on the add a devtool dropdown

Pressing the add devtool button shows a dropdown with the different devtools you can add.

2. Open a new terminal

When selecting the terminal devtool option in the dropdown a sub menu shows up with the option to add a new terminal.

3. Run a docker image

Inside the terminal a command is pasted to run the docker image.

4. Opened ports will be picked up automatically

If you run a development server for example inside the container and it opens up a port then Projects will detect that automatically and make the preview available. You can open the preview from the Other Previews in this case.

The devtools have an option with other previews. Selecting this option will shows a submenu with ports running the previews.

5. If you would like to start the given container every time you create a new branch or even restart your projects then you can persist it as a task

When opening the devtools menu and selecting tasks, a submenu with your tasks and an option to add a new task is shown. The new task option is highlighted.

6. Just paste the command to the Command Palette and Projects will create a configuration file

The command palette is shown with an indicator that the current action is adding a task, and the command is pasted inside the input.

7. Put it in the right place in your configuration

If you define it as a task you will be able to run the container from the UI. You can also put it under setupTask and in this case the container will start when you create a workspace next time.

Tip: Commit your changes and add the configuration to your repository so Projects will be able to run the container for every newly created branch.

The tasks.json file is open in the editor and shows all tasks that exist for the project.

Last updated on August 25, 2022