#🔒 Docker Error when Binding Volume
53 messages · Page 1 of 1 (latest)
@tropic dagger
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Im not exactly sure why?
this is my dockerfile
# Use an official Python runtime as a parent image
FROM python:3.9-slim
# Set the working directory
WORKDIR /app
# Copy the requirements file
COPY requirements.txt ./
# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application code
COPY . /app
# Command to run the application
CMD ["python", "main_bot.py"]
If you bind a directory from the host into the container, it will hide whatever's at the in-container mount point. You're binding it to /app, hiding what you copied into /app in the dockerfile.
How can I fix this?
Cuz im still learning docker, it's been a confusing process despite all the videos
Bind it to somewhere else? Or copy main_bot.py etc to somewhere else
I just want the program files to be mounted to a specific location so if I every update or delete the bot, all the settings stay there
That looks like it isn't the directory you mounted in?
It's got spaces in the name in the screenshot above.
With how i've learned docker, for example when I build it. All this goes to "/app"
I use visual studio code to push this into docker hub
/app is a typical place to install whatever you're plonking into the container.
I pull it from docker hub onto my home server,
and so I tried to redirect /app to /mnt/cloud1/Example/app
So your VSCode above is not on the home server. Where's /mnt/cloud1 come from? Is it related to whatever VSCode is looking at?
/mnt/cloud1 is a mounted drive on my home server
which is running ubuntu server
basically anything inside that directory goes to my 2TB Hard Drive
But, that's a whole thing
Basically my issue is, I don't understand why changing the volume causes this issue
because technically speaking, inside the docker container, all it sees is still /app, it doesn't know it's inside /mnt/cloud1/Example/app
unless that isn't how that works
Right. So I'm assuming that after you bind it in, /app doesn't contain what it should.
So where's the container running? That GUI above with the mount options. Loca to your dev box with VSCode, or remote on your home server?
Sort of like a remote yes
im accessing portainer from a web browser
Portainer is basically a web UI for docker
I mean, I guess for now I just don't mount it to a specific path like im trying.
Ok. Back to the container. Running on your home server? Running in the cloud at portainer somehow?
So this:
is the portainer web UI?
If it's local, can you look in that directory?
Well then you've mounted am empty directory onto /app, and thus there's no main_bot.py. Do I misunderstand?
Well,
this is what the docker container should create when it pulls from docker hub
That's inside the container?
yes, this is inside the container
Yes. That's what's there before you bind in this other directory.
but I wanted to push this to be in /mnt/cloud1 on my main host
So /mnt/cloud1 is off yoru 2TB drive on the home server?
yes
Can you rsync from your (local?) VSCode directory onto that? To make the copy at home (in the currently empty cloud1/DATA/gumroad-product-announcer-discordbot directory) have your dev files?
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.