How to enable docker?

# To learn more about how to use Nix to configure your environment
# see: https://developers.google.com/idx/guides/customize-idx-env
{ pkgs, ... }: {
  # Which nixpkgs channel to use.
  channel = "stable-24.05"; # or "unstable"
  # Use https://search.nixos.org/packages to find packages
  packages = [
    pkgs.service-wrapper
    pkgs.go
    pkgs.air
    pkgs.docker
  ];
  # Sets environment variables in the workspace
  services.docker.enable = true;
  idx = {
    # Search for the extensions you want on https://open-vsx.org/ and use "publisher.id"
    extensions = [
      "golang.go"
      "rangav.vscode-thunder-client"
      "ms-azuretools.vscode-docker"
    ];
    workspace = {
      onCreate = {
        # Open editors for the following files by default, if they exist:
        default.openFiles = ["main.go"];
      };
      # Runs when a workspace is (re)started
      onStart= {
        run-server = "air";
      };
      # To run something each time the workspace is first created, use the `onStart` hook
    };
  };
}

Having my nix file, it is not starting my docker service:

docker version
Client:
Version: 25.0.6
API version: 1.44
Go version: go1.22.6
Git commit: v25.0.6
Built: Thu Jan 1 00:00:00 1970
OS/Arch: linux/amd64
Context: default
Cannot connect to the Docker daemon at unix:///tmp/docker.sock. Is the docker daemon running?

1 Like

This might be something that @davideast, @Alex, or @Vova can help you out around :slight_smile:

1 Like

I’m having this issue too, just started an empty testing project, added services.docker.enable = true; and I’m receiving the error.

Seems fixed for some reason :eyes:

Tried out with the same project and its working now.

One thing to note is that you don’t need the pkgs.docker declaration, that is included when you register it as a service.

https://youtu.be/_l-y4edAmFU?si=F34ti7cjgh7dQXWu