Error while creating mount source path due to read only file system

Hello all,

i’m new with docker en i’m running into an issue.
i’m running the command “docker compose up” and and i’m getting the following error.
Error response from daemon: error while creating mount source path ‘/opt/portainer’: mkdir /op t/portainer: read-only file system.

but I think I “enabled” all permissions (maybe too much) as you can see here:

drwxrwxrwx 4 root root 4096 Jul 16 16:22 containerd
-rwxrwxrwx 1 root root 689 Jul 17 13:15 docker-compose.yaml
drwxrwxrwx 3 root root 4096 Jul 16 15:35 homeassistant
drwxrwxrwx 8 root root 4096 Jul 16 15:35 portainer

docker compose version is: v2.38.2

the docker-compose.yaml file is:

services:
  portainer:
    container_name: portainer
    image: portainer/portainer
    restart: always
    ports:
      - "9000:9000/tcp"
    environment:
      - TZ=Europe/Amsterdam
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /opt/portainer:/data
  homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:stable"
    volumes:
      - /opt/homeassistant/config:/config
      - /etc/localtime:/etc/localtime:ro
      - /run/dbus:/run/dbus:ro
    restart: unless-stopped
    privileged: true
    network_mode: host

I hope I have give you all the information you need to help me out.

Looks like your host filesystem is read-only.

Please share the output of:

stat /opt/portainer

and the output of this:

sudo docker info

thank you for the quick response.

the output of stat /opt/portainer

 File: /opt/portainer
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: 252,0   Inode: 1441794     Links: 8
Access: (0777/drwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2025-07-25 15:45:01.915071027 +0000
Modify: 2025-07-16 15:35:40.307005035 +0000
Change: 2025-07-17 13:39:25.504723894 +0000
 Birth: 2025-07-16 15:35:39.836957446 +0000

the response of sudo docker info is:

Client: Docker Engine - Community
 Version:    28.3.2
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.24.0
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.38.2
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 3
  Running: 0
  Paused: 0
  Stopped: 3
 Images: 3
 Server Version: 28.1.1+1
 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 splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 05044ec0a9a75232cad458027ca83437aae3f4da
 runc version:
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.14.0-24-generic
 Operating System: Ubuntu Core 22
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 7.142GiB
 Name: dijkserver
 ID: 6f05f25d-36a9-4c55-b44c-f0532685582d
 Docker Root Dir: /var/snap/docker/common/var-lib-docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  ::1/128
  127.0.0.0/8
 Live Restore Enabled: false

Oh, I see the problem: you are using the snap package of docker.

I always considered the snap version as broken, as it does not behave like vanilla docker. Furthermore, the snap version and versions from distribution repositories are not supported in this forum.

I highly recommend removing the snap package and install docker-ce, the vanilla docker distribution, from Docker’s repositories: https://docs.docker.com/engine/install/ubuntu/.

Thank you, this solved the issue!

its a few days later but now i have the same issue while i using the command docker start container (name)
so it looks like it is not solved.
here again the results of the two commands after i installed the correct docker version.
stat /opt/portainer

  File: /opt/portainer
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: 252,0   Inode: 1441794     Links: 8
Access: (0777/drwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2025-07-28 18:45:04.838825263 +0000
Modify: 2025-07-16 15:35:40.307005035 +0000
Change: 2025-07-17 13:39:25.504723894 +0000
 Birth: 2025-07-16 15:35:39.836957446 +0000 

and sudo docker info

Client: Docker Engine - Community
 Version:    28.3.2
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.25.0
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.38.2
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 3
  Running: 0
  Paused: 0
  Stopped: 3
 Images: 3
 Server Version: 28.1.1+1
 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 splunk syslog
 Swarm: inactive
 Runtimes: runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 05044ec0a9a75232cad458027ca83437aae3f4da
 runc version:
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.14.0-24-generic
 Operating System: Ubuntu Core 22
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 7.142GiB
 Name: dijkserver
 ID: 6f05f25d-36a9-4c55-b44c-f0532685582d
 Docker Root Dir: /var/snap/docker/common/var-lib-docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  ::1/128
  127.0.0.0/8
 Live Restore Enabled: false

what can be issue here? it was working but it seems to appear after I exit ssh terminal and did not touch it for a few day.

I’m not sure about that. Your docker info still shows Ubuntu Core 22 as operating system, so this still looks like a snap package.

And your server and client have different versions

I have never seen +1 in any Docker CE version without Snap, but it is indeed a snap package version

channels:
  latest/stable:    28.1.1+1 2025-06-30 (3267) 125MB -

Please, check the instructions shared by @meyay again and make sure you remove the snap package as otherwise it is possible you run multiple docker daemons and you still connect to the wrong one.

snap remove docker

or

snap remove --purge docker

Rebooting the host machine could also be required.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.