1

I’m facing an issue while trying to run a GitLab Runner container on my machine. The command I’m using is:

sudo docker run -d --privileged --name gitlab-runner --restart always \
  -v /srv/gitlab-runner/config:/etc/gitlab-runner \
  -v /var/run/docker.sock:/var/run/docker.sock \
  gitlab/gitlab-runner:latest

But every time I run this, I get the following error:

docker: Error response from daemon: error while creating mount source path '/srv/gitlab-runner/config': mkdir /srv/gitlab-runner: read-only file system.

Things I’ve Tried:

Changing Directory Permissions I attempted to modify the permissions on the /srv directory by running:

sudo chown 1000:1000 /srv/gitlab-runner But this didn’t resolve the issue.

Checking Mount Options I used the mount command to verify if /srv (or the root / file system) was mounted as read-only. It seems to be mounted as read-only (ro).

Trying to Remount I attempted to remount /srv as read-write:

sudo mount -o remount,rw /srv This did not work either, and I’m still facing the same read-only error.

Question:

Does anyone know why Docker is unable to create directories in /srv and why it's mounted as read-only? Could this be due to specific settings in Debian, or something related to Docker’s permissions? Any solutions or workarounds to allow /srv/gitlab-runner/config to be writable by Docker would be greatly appreciated!

Thank you in advance for your help!

The output of docker info is:

sudo docker info
Client: Docker Engine - Community
 Version:    27.3.1
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.17.1
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.29.7
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 2
  Running: 1
  Paused: 0
  Stopped: 1
 Images: 2
 Server Version: 24.0.5
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 3dce8eb055cbb6872793272b4f20ed16117344f8
 runc version:
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.15.0-124-generic
 Operating System: Ubuntu Core 22
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 15.61GiB
 Name: machine1
 ID: b356d3b3-4571-4b1b-8130-1a6aa7bc2c9d
 Docker Root Dir: /var/snap/docker/common/var-lib-docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
7
  • hi. every time I run this, I get the following error "Where" do you get the error? In the terminal right after running the command? Are there any other mesasges? Do you see anythnig in journalctl or systemctl status docker? On the host what is the output of findmnt or mount? Are you executing the command inside another docker container? What is the output of docker info? is DOCKER_HOST variable set? Are you sure you want to do that? Why are you using privileged if you are mounting docker.sock from host? Commented Oct 31, 2024 at 13:10
  • @KamilCuk hello, yes in the terminal, I am working on virtual machine ubuntu and after executiung the command of docker run i got this error of read-only. The problem that I already created a gitlab container "sudo docker run --restart always --privileged -d --name gitlab --hostname 192.168.26.27 -p 80:80 -p 2224:22 -p 1443:443 -v $GITLAB_HOME/config:/etc/gitlab -v $GITLAB_HOME/logs:/var/log/gitlab -v $GITLAB_HOME/data:/var/opt/gitlab docker.io/gitlab/gitlab-ce:17.5.0-ce.0" and works fine for me with $GITLAB_HOME is /srv/gitlab Commented Oct 31, 2024 at 13:21
  • Hi The problem that I why or how is that aproblem? Commented Oct 31, 2024 at 13:25
  • /var/snap/docker/common/var-lib-docker Your docker is running in snap? I guess this might be an issue, but I know nothing about snap. Commented Oct 31, 2024 at 13:25
  • @KamilCuk sorry not the right words, I mean I have a gitlab container on the same machine using the srv directory and working very fine, i didn't modify anything in the VM and these are the permissions machine1@machine1:/srv/gitlab$ ll total 20 drwxr-xr-x 5 machine1 machine1 4096 oct. 30 16:00 ./ drwxr-xr-x 4 root root 4096 oct. 31 12:40 ../ drwxr-xr-x 2 machine1 machine1 4096 oct. 30 16:00 config/ drwxr-xr-x 2 machine1 machine1 4096 oct. 30 16:00 data/ drwxr-xr-x 2 machine1 machine1 4096 oct. 30 16:00 logs/ i tried the same for gitlab-runner but did not work Commented Oct 31, 2024 at 13:31

1 Answer 1

2

I had this problem on Ubuntu 22.04. Perhaps it's due to a similar cause in Debian.

If you are using the snap-managed Docker installation, then it is sand-boxed in a way that prevents it from writing to files outside of the sandbox, such as /srv.

You may wish to switch to the APT-managed docker-ce package instead.

See here for more: https://stackoverflow.com/a/54492532/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.