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

Docker relative bind mounts become /compose/<name> instead of the actual abousolte path. #189

Open
ajh123 opened this issue Dec 23, 2024 · 1 comment

Comments

@ajh123
Copy link

ajh123 commented Dec 23, 2024

BurmillaOS Version: (ros os version)

v2.0.2-rc2

Where are you running BurmillaOS? (docker-machine, AWS, GCE, baremetal, etc.)

Hyper V on Windows:

Edition	Windows 11 Pro
Version	23H2
Installed on	‎16/‎06/‎2024
OS build	22631.4602
Experience	Windows Feature Experience Pack 1000.22700.1055.0

Which processor architecture you are using?

x86 64 (AMD Ryzen 7 5800H with Radeon Graphics)

Do you use some extra hardware? (GPU, etc)?

No

Which console you use (default, ubuntu, centos, etc..)

Default

Do you use some service(s) which are not enabled by default?

No

Have you installed some extra tools to console?

cifs-utils, tree

Do you use some other customizations?

Does creating docker containers count?

Please share copy of your cloud-init (remember remove all sensitive data first)

mounts:
- - //<REDACTED>/shares
  - /mnt/SHARES
  - cifs
  - username=<REDACTED>,password=<REDACTED>,uid=1000,gid=1000,dir_mode=0777,file_mode=0777
rancher:
  docker:
    engine: docker-27.3.1
  environment:
    EXTRA_CMDLINE: /init
  services_include:
    hyperv-vm-tools: true
  state:
    dev: LABEL=RANCHER_STATE
    wait: true
ssh_authorized_keys:
- ssh-ed25519 AAAAC3N<REDACTED>

I'm trying to run a simple NginX container but the bind mount inside the container is empty.

My direcory is set up like:

.
|-- docker-compose.yml
`-- nginx
    |-- conf.d
    |   `-- default.conf
    `-- html
        `-- index.html

My docker-compose.yml is:

name: NginX
services:
  nginx:
    image: nginx:alpine
    ports:
      - "0.0.0.0:80:80"
    volumes:
#      - ./nginx/conf.d:/etc/nginx/conf.d # disabled becuase the container thinks `default.conf` is a directory
      - ./nginx/html/:/usr/share/nginx/html/
      - ./nginx/cert/:/etc/ssl/private/
    restart: always

My problem is when I try to access the NginX server I get a "403 Forbidden" (due to the /usr/share/nginx/html/ directory being empty) and a "404 Not Found" directly on the index page.

If I use docker inspect on the container I get:

        "Mounts": [
            {
                "Type": "bind",
                "Source": "/compose/nginx/cert",
                "Destination": "/etc/ssl/private",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/compose/nginx/html",
                "Destination": "/usr/share/nginx/html",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],

The significant problem here is that /compose/nginx is not my directory but /home/rancher/DOCKER/NginX is.

If I change the docker compsoe file to:

services:
  nginx:
    image: nginx:alpine
    ports:
      - "0.0.0.0:80:80"
    volumes:
      - /home/rancher/DOCKER/NginX/nginx/conf.d:/etc/nginx/conf.d
      - /home/rancher/DOCKER/NginX/nginx/html/:/usr/share/nginx/html/
      - /home/rancher/DOCKER/NginX/nginx/cert/:/etc/ssl/private/
    restart: always

then everything works as expected.

TLDR:

  • Relative mounts (e.g. ./host/path:/container/path) become /compose/host/path instead of the actual path.
  • Use the abousolte path to fix this.

If this is intended behaviour should the documentation be updated?

@olljanat
Copy link
Member

This issue is most likely related to #168 (comment) and basically means that we need figure out alternative solution to handling compose binary packaging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants