Use mount -a to mount a zip file when building docker image

I’m trying to build a docker image for https://openfreemap.org/ which is using hard linked files. I was hoping to be able to use the naive approach to simply run the init script in a Dockerfile. The init script is mounting a zip file by the following entry in /etc/fstab

data/ofm/http_host/runs/monaco/20250720_231000_pt/tiles.btrfs /mnt/ofm/monaco-20250720_231000_pt btrfs loop,ro 0 0

The file tils.btrfs and the mount path exists, but the “mount -a” command fails with the following error:

mount: /mnt/ofm/monaco-20250720_231000_pt: mount failed: No such file or directory.

I’ve also tried to log into an ubuntu container an run the script and get the same error.

Here is a Dockerfile that reproduces the error when built

# Run with docker build --file ./Dockerfile .
FROM ubuntu:latest

RUN apt update && apt install -y \
sudo \
git \
python3-pip \
python3.12-venv \
openssh-server
# setting up ssh
RUN ssh-keygen -t ed25519 -C "your_email@example.com" -f /root/.ssh/id_ed25519 -N ""
RUN cp /root/.ssh/id_ed25519.pub ~/.ssh/authorized_keys
RUN /etc/init.d/ssh start
# setting up code
WORKDIR /checkout
RUN git clone https://github.com/hyperknot/openfreemap
WORKDIR /checkout/openfreemap
COPY config/env.sample /checkout/openfreemap/config/.env

RUN python3 -m venv py_envs
RUN . /checkout/openfreemap/py_envs/bin/activate && pip install -e .
# THE FAILING LINE IS init-server.py
RUN . /checkout/openfreemap/py_envs/bin/activate && /etc/init.d/ssh start && ./init-server.py http-host-static 127.0.0.1 -y

 CMD ["echo", "Hello, World!"]

Hello!
I am having the same issue. Appreciate if anyone knows the solution.

It feels like you are trying to mount a file from the host when you are inside the container. If you want to mount a file, you need to use a bind mount

For compose

Search for bind

When you build an image, you still have a container running the instructions.

You can search for “–mount” here. And either you mount a file or copy, but a simople mount command will not work as it will see only the files inside the container.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.