Coder.comC
Coder.com12mo ago
8 replies
Chris2pi

newgrp not working in startup script

This might just be a Linux 101 issue but still can't work out why.

We have a custom built AMI with Docker installed and want to grant the Coder user access to use Docker.
Since the Coder user doesn't exist on the AMI yet I added the commands to the startup_script in resource "coder_agent"

The script runs
 newgrp docker 
and it doesn't appear to work.
We run the same command in the terminal and it works.

So maybe something strange is happening with the session?

resource "coder_agent" "dev" {
  count          = data.coder_workspace.me.start_count
  arch           = "amd64"
  auth           = "aws-instance-identity"
  os             = "linux"
  startup_script_behavior = "blocking"
  startup_script = <<-EOT
    set -e

    # Add any commands that should be executed at workspace startup (e.g install requirements, start a program, etc) here
    # docker group already exists
    sudo usermod -aG docker coder
    newgrp docker
Was this page helpful?