Skip to content

Bind mount throws error if the directory does not exit beforehand #1652

Closed
@mirzaprangon

Description

@mirzaprangon

Description

Discussed in rancher-sandbox/rancher-desktop#3603

Hello
I am running nerdctl on windows, using rancher desktop version 1.6.2.
I have a simple compose file with directory mounts, nothing fancy just a mysql container.

services:
  mysql_db:
    image: mysql:8.0.30
    restart: always
    volumes:
      - ./mysql_db_data:/var/lib/mysql
      - ./mysql_db_config:/etc/mysql/conf.d
    environment:
      - MYSQL_DATABASE=keycloak
      - MYSQL_ROOT_PASSWORD=root_password
      - MYSQL_USER=db_user
      - MYSQL_PASSWORD=db_password
      - TZ=Asia/Tokyo

But nerdctl compose up fails if I run without the mount directory manually first. The output I get with --debug option is as follow

WARN[0000] Ignoring: volume: Bind: [CreateHostPath]
WARN[0000] Ignoring: volume: Bind: [CreateHostPath]
INFO[0000] Ensuring image mysql:8.0.30
DEBU[0000] filters: [labels."com.docker.compose.project"==20221213githubtokenforjenkinsjobincoverity,labels."com.docker.compose.service"==mysql_db]
INFO[0000] Creating container mysql_mysql_db_1
FATA[0000] error while creating container mysql_mysql_db_1: exit status 1

I can run the compose file if I change my container engine to Dockerd/moby and use docker compose up.
If I remove the volume binds I can run the compose file with nerdctl compose up.

nerdctl compose and nerdctl run -v S\should make empty mount directories if those do not already exist like docker compose and docker run -v in windows.

Steps to reproduce the issue

  1. run nerdctl run -v mysql_db_data:/var/lib/mysql mysql:8.0.30 without creaating the mysql_db_data directory in the host.

Or

  1. Run nerdctl compose up with follwing compose file.
    services:
      mysql_db:
        image: mysql:8.0.30
        restart: always
        volumes:
          - ./mysql_db_data:/var/lib/mysql
    

Describe the results you received and expected

Recieved
nerdctl run -v mysql_db_data:/var/lib/mysql mysql:8.0.30 fails with following error

FATA[0000] failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/mnt/c/Users/mirzap/Works Folder/mysql/mysql_db_data" to rootfs at "/var/lib/mysql": stat /mnt/c/Users/mirzap/Works Folder/mysql/mysql_db_data: no such file or directory: unknown

nerdctl compose up fails with following error.

WARN[0000] Ignoring: volume: Bind: [CreateHostPath]
WARN[0000] Ignoring: volume: Bind: [CreateHostPath]
INFO[0000] Ensuring image mysql:8.0.30
DEBU[0000] filters: [labels."com.docker.compose.project"==20221213githubtokenforjenkinsjobincoverity,labels."com.docker.compose.service"==mysql_db]
INFO[0000] Creating container mysql_mysql_db_1
FATA[0000] error while creating container mysql_mysql_db_1: exit status 1

Expected
nerdctl to create the bind mount directory if it does not already exist and container properly starts without any error.

What version of nerdctl are you using?

Client:
Version: v0.23.0
OS/Arch: linux/amd64
Git commit: 660680b
buildctl:
Version: v0.10.4
GitCommit: a2ba6869363812a210fcc3ded6926757ab780b5f

Server:
containerd:
Version: v1.6.8
GitCommit: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
runc:
Version: 1.1.4
GitCommit: 5fd4c4d144137e991c4acebb2146ab1483a97925

Are you using a variant of nerdctl? (e.g., Rancher Desktop)

Rancher Desktop for Windows

Host information

Client:
Namespace: default
Debug Mode: false

Server:
Server Version: v1.6.8
Storage Driver: overlayfs
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Log: fluentd journald json-file
Storage: native overlayfs
Security Options:
seccomp
Profile: default
Kernel Version: 5.10.16.3-microsoft-standard-WSL2
Operating System: Rancher Desktop WSL Distribution
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 12.24GiB
Name: 11-11569698
ID: 8e7f6d3b-981b-48f3-81ac-40260dd40697

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions