How to automatically create mounted directory?
I use compose like this:
services:
mysql:
image: mysql:8.0
environment:
- MYSQL_ROOT_PASSWORD=root
ports:
- 3306:3306
volumes:
- ../../data/mysql/var/lib/mysql/:/var/lib/mysql/
Which works with docker-compose:1.29.* (pip install docker-compose), the mounted directory will be created automatically as follow:
/d/docker
|--linux
|--mysql
|--docker-compose.yml
|--data # automatically created
|--var
|--lib
|--mysql
However, nerdctl compose up -d got:
FATA[0000] failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:76: mounting "/d/docker/data/mysql/var/lib/mysql" to rootfs at "/var/lib/mysql/" caused: stat /d/docker/data/mysql/var/lib/mysql: no such file or directory: unknown
Am I using it as wrong way?
If you dont need to bind the exact directory, you can change the type from from Bind (compose detects the path there) and put into Volume mode. Something like:
volumes:
- mysql_data:/var/lib/mysql/
or
volumes:
- type: Volume
target: /var/lib/mysql/
source: mysql_data
I'm studying the code for a possible adjust. But I'm new here. :-)
@jopapo @AkihiroSuda
Is there something new you can share with us?
I get the same error mentioned by @icefery and can't figure it out how to get it to run. I couldn't get it to run with the Volume mode either.
myimage:
network_mode: bridge
build: ./myimage
dns:
- 8.8.8.8
ports:
- 443:443
volumes:
- /tmp/myvolume:/tmp/myvolume:z
FATA[0000] failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:75: mounting "/tmp/myvolume" to rootfs at "/tmp/myvolume" caused: stat /tmp/myvolume: no such file or directory: unknown
Interesting(?) sidefact: I tried the same setup with Docker/Docker Desktop and got the same error but as soon as I disabled "Use gRPC FUSE for file sharing" and started using the legacy osfx file sharing it worked.
I've ran into this issue too. To me (and I'll admit I'm not an expert at all), it seems nerdctlis trying to access the file system as root and not as the current user. Thus, for instance, my binding to ~/data/mongodb goes to /home/root/data/mongodb and that directory doesn't exist and can't be created, because root is "disabled".
Using the volume mode worked though. So, thanks @jopapo for the tip.
Scott
I've ran into this issue too.