Skip to content

Failed to start: chown: /var/opt/sourcegraph/postgresql: Operation not permitted (with Docker on Ubuntu)

Created by: apjanke

  • Sourcegraph version: 3.25.2
  • Platform information: Ubuntu 18.04.5 LTS running on an Azure VM

I am just now trying to use Sourcegraph for the first time. I'm setting up a development/testing instance using the "Docker" method, and it's failing to start up.

Steps to reproduce:

Context:

apjanke@lx-azrdev01:~/.sourcegraph $ pwd
/home/apjanke/.sourcegraph
apjanke@lx-azrdev01:~/.sourcegraph $ ls -l
total 12
drwxrwxrwx 3 apjanke developer 4096 Mar 16 10:12 config
drwxrwxrwx 5 apjanke developer 4096 Mar 16 10:15 data
-rwxrwxrwx 1 apjanke developer  333 Mar 16 10:06 run_sourcegraph
apjanke@lx-azrdev01:~/.sourcegraph $ cat run_sourcegraph
#!/bin/bash

docker run \
  --publish 7080:7080 \
  --publish 127.0.0.1:3370:3370 \
  --rm \
  --volume ~/.sourcegraph/config:/etc/sourcegraph \
  --volume ~/.sourcegraph/data:/var/opt/sourcegraph \
  sourcegraph/server:3.25.2

if [[ $? = 0 ]]; then
  echo Sourcegraph started
else
  echo >&2 ERROR: Sourcegraph failed to start!
fi

apjanke@lx-azrdev01:~/.sourcegraph $
  1. Set up the above script, using the command copied from https://docs.sourcegraph.com/admin/install/docker
  2. ./run_sourcegraph

Expected behavior:

Sourcegraph starts up without error?

Actual behavior:

Fails to start, complaining about a failure to change ownership on /var/opt/sourcegraph/postgresql. (I assume it's talking about /var/opt/sourcegraph/postgresql inside the Docker container, and not on my main Linux machine?)

apjanke@lx-azrdev01:~/.sourcegraph $ ./run_sourcegraph
✱ Sourcegraph is initializing the internal database... (may take 15-20 seconds)
✱ Setting up postgres failed:

$ /bin/mkdir mkdir -p /var/opt/sourcegraph/postgresql

$ /bin/chown chown postgres /var/opt/sourcegraph/postgresql
chown: /var/opt/sourcegraph/postgresql: Operation not permitted

exit status 1
ERROR: Sourcegraph failed to start!
apjanke@lx-azrdev01:~/.sourcegraph $ 

Any ideas how to fix?

Thanks for providing this free-trial software, by the way!