Here are my definitions:
- structure:
.devcontainer
devcontainer.json
docker
bot
Dockerfile
entrypoint.sh
docker-compose.base.yaml
docker-compose.dev.yaml
pdm.lock
...
devcontainer.json:
{
"name": "SomeName",
"dockerComposeFile": [
"../docker/docker-compose.base.yml",
"../docker/docker-compose.dev.yml",
],
"service": "bot",
"shutdownAction": "stopCompose",
"workspaceFolder": "/mounted",
}
docker-compose.base.yaml(thedevone is currently just emptyservices: {}):
version: '3.9'
services:
bot:
build:
context: ..
dockerfile: docker/bot/Dockerfile
volumes:
- '../:/mounted'
restart: unless-stopped
Dockerfile:
FROM python:3.11.5
WORKDIR /mounted
ENV PIP_ROOT_USER_ACTION ignore
ENV PYTHONUNBUFFERED 1
RUN apt-get update && apt-get install -y --no-install-recommends \
nano \
vim \
grc \
git \
htop \
iptraf \
&& apt-get purge -y --auto-remove \
&& apt-get clean \
&& rm -fr /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN pip install -U pip pdm && pdm sync
COPY docker/bot/entrypoint.sh /usr/local/bin/
RUN chmod a+x /usr/local/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
The build of the container fails on pdm sync command, which requires pdm.lock to be mounted and present. And it is mounted normally when using docker-compose up directly.
When I added directory listing:
RUN pip install -U pip pdm && ls -a && pdm sync
that reported only . and .. as options, so /mounted is empty.
Why is the volume not mounted correctly? What can I do to fix it?