找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
听天命
查看: 1019|回复: 0

Docker - mkdir read-only file system

[复制链接]

54

主题

6

回帖

40万

积分

管理员

积分
400064

最佳新人活跃会员热心会员推广达人宣传达人灌水之王突出贡献优秀版主荣誉管理论坛元老

发表于 2024-4-23 09:41:01 | 显示全部楼层 |阅读模式
After freshly installing Ubuntu 18 I am receiving the following error when trying to launch a docker container that has a bind to a LVM (ext4) partition:

  1. mkdir /storage: read-only file system
复制代码
I have tried reinstalling the OS, reinstalling Docker and forcing the drive to mount as RW (everything that isn't docker can write to the drive).
The directory that is being bound is currently set to 777 permissions.
There seems to be almost no information available for this error.
Try removing docker from snap and reinstalling it following the official docker steps.
Remove docker from snap:
  1. snap remove docker
复制代码
hen remove the docker directory and the old version:
  1. rm -R /var/lib/docker

  2. sudo apt-get remove docker docker-engine docker.io
复制代码
Install official docker: [color=var(--theme-link-color, var(--theme-secondary-400))]https://docs.docker.com/install/linux/docker-ce/ubuntu/
Update 01/2021: while still pretty cool, Snaps don't always work. Specifically with the Docker Snap, it didn't work for Swarm mode, so I ditched it and [color=var(--theme-link-color, var(--theme-secondary-400))]installed Docker the recommended way.
Snaps are actually pretty cool, IMO, and think it's beneficial to run Docker within a Snap than installing it directly on the system. The fact that you're getting a read-only permissions error is a good thing. It means that a rogue container isn't able to wreak havoc on your base OS. That said, how to fix your issue.
The reason that this is coming up is that Snaps will expose the host OS as read-only so that Docker can see the host's files, but not modify them (hence the permission denied error). But there is a directory that the Docker Snap can write to: /var/snap/docker. Actually, a better directory that snap can write to is /home. I created /home/docker for containers to have persistent storage from the host system.
In your case, you wanted /storage to be writable by Docker containers. I had a very similar use-case, which led me to this SO post. I solved this by mounting my storage within the docker snap directory /home/docker; the easiest example simply being a directory on the same filesystem:
  1. mkdir -p /home/docker/<container name>/data
复制代码
In my case, I created a ZFS dataset at the location above instead of simply mkdir'ing a directory.
Then, the container I ran could write to that with something like:
  1. docker run -ti -v /home/docker/<container name>/data:/data [...]
复制代码
Now you have the best of both worlds: Docker running in a contained Snap environment and persistent storage.
you can create/run your container with --privileged:
ex.:
  1. docker run --privileged -i --name master --hostname k8s-master -d ubuntu:20.04
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

精简版|手机版|嗐!无思百忧,祇自重兮 ( 京ICP备18055970号|京ICP备18055970号 )晋公网安备 14010902001813号 劰载中... 本站总访问量次. 您是第个小伙伴

GMT+8, 2026-1-25 17:49 , Processed in 0.085663 second(s), 25 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表