Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] bind mount not propagated into tmpfs mount point #12538

Closed
cherusk opened this issue Feb 8, 2025 · 2 comments
Closed

[BUG] bind mount not propagated into tmpfs mount point #12538

cherusk opened this issue Feb 8, 2025 · 2 comments

Comments

@cherusk
Copy link

cherusk commented Feb 8, 2025

Description

If one uses tmpfs volumes and tries to bind mount into those, the directory mounted from the host node will not appear in the container.

That might be as designed and hence might not be a bug.

Yet that behavior was unexpected for me and startled me.

Steps To Reproduce

That does not work:

  kube-worker-1:
    image: docker.io/k0sproject/k0s:v1.31.5-k0s.0
    container_name: kube-worker-1
    hostname: kube-worker-1
    cgroup: host
    deploy:
      resources:
        limits:
          cpus: '1.0'
          memory: 1g
        reservations:
          cpus: '0.5'
          memory: 500m
    privileged: true
    restart: always
    depends_on:
      - kube-master
    volumes:
      - "kube-master-shared:/shared"
      - "kube-worker-1:/var/lib/k0s"
      - "/github-runner/godon-charts/godon-charts/:/script/"
      # for openebs hostpath storage
      - "/srv/storage/:/var/openebs/local"
      #### >>> NOTE ME - /run/udev will never appear in container
      - "/run/udev/:/run/udev/" 
    tmpfs:
    - /run
    - /var/run
    network_mode: "bridge"
    command: /bin/sh /script/worker_join.sh

That works

  kube-worker-1:
    image: docker.io/k0sproject/k0s:v1.31.5-k0s.0
    container_name: kube-worker-1
    hostname: kube-worker-1
    cgroup: host
    deploy:
      resources:
        limits:
          cpus: '1.0'
          memory: 1g
        reservations:
          cpus: '0.5'
          memory: 500m
    privileged: true
    restart: always
    depends_on:
      - kube-master
    volumes:
      - "kube-master-shared:/shared"
      - "kube-worker-1:/var/lib/k0s"
      - "/github-runner/godon-charts/godon-charts/:/script/"
      # for openebs hostpath storage
      - "/srv/storage/:/var/openebs/local"
      - "/run/udev/:/run/udev/"
   ##### >>> NOTE ME --  This solves the issue, not using tmpfs overall
    #tmpfs:
    #- /run
    #- /var/run
    network_mode: "bridge"
    ##### <<< NOTE ME 
    command: /bin/sh /script/worker_join.sh

Compose Version

Docker Compose version 2.27.0

Docker Environment

Client:
 Version:    25.0.6
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.14.0
    Path:     /nix/store/z7p0h51f3h24a98fjpimz5dg8q6phkr4-docker-plugins/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  2.27.0
    Path:     /nix/store/z7p0h51f3h24a98fjpimz5dg8q6phkr4-docker-plugins/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 3
  Running: 3
  Paused: 0
  Stopped: 0
 Images: 1
 Server Version: 25.0.6
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: journald
 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: v1.7.16
 runc version:
 init version:
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.12.7
 Operating System: NixOS 24.05 (Uakari)
 OSType: linux
 Architecture: x86_64
 CPUs: 12
 Total Memory: 31.35GiB
 Name: nixos
 ID: de015430-4ba2-44b0-a67c-3eb74da0dc34
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: true

Anything else?

No response

@ndeloof
Copy link
Contributor

ndeloof commented Feb 10, 2025

I can't reproduce. Can you please try this minimal example:

$ cat compose.yaml 
services:
  webapp:
    image: alpine
    command: ls /run
    volumes:
      - .:/run/test
    tmpfs:
      - /run

$ docker compose up
[+] Running 1/1
 ✔ Container truc-webapp-1  Created                                                                                                             0.0s 
Attaching to webapp-1
webapp-1  | test
webapp-1 exited with code 0

@cherusk
Copy link
Author

cherusk commented Feb 10, 2025

@ndeloof confirming, cannot reproduce it with your minimal sample snippet either.

Then is might be something specific to k0s docker container image.

I will not use k0s further.

We can close hence.

Thanks for your time.

@cherusk cherusk closed this as completed Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants