Code: Select all
python:3.11-slim-bookworm
Code: Select all
services:
app:
...
volumes:
- ./src:/app
< /code>
Ich verwende "Dev -Container: Anhängen zum Auslaufcontainer ..." von meinem 1. VSCODE Projekt (das mit Docker gestartet wurde, komponieren Sie -d
Code: Select all
import os
# This first print is fine and reflecting the actual path inside the container:
print("Current working directory in Jupyter:", os.getcwd())
# Current working directory in Jupyter: /app
# This second print is getting me crazy because there is no such intermediary src/ folder
# inside the container:
print("My script folder path in Jupyter:", os.path.abspath(__file__))
# My script folder path in Jupyter: /app/src/mymodule/my_script.py
Meine Ordnerstruktur aus dem Container ist wie folgt: < /p>
Code: Select all
user@app-container:/app$ tree -L 2
.
├── __init__.py
├── mymodule
│ ├── __init__.py
│ └── my_script.py
└── app.py
< /code>
Kann jemand erklären, warum VSCODE einen Ordner im Container im Container sieht? Das Wort "src" befindet sich im Abschnitt "Volumen < /code>" meiner oben beschriebenen Komponierungsdatei und es geht nur um einen Pfad auf meinem Localhost, nicht im Container. BASH -Terminal im zweiten Fenster VSCODE 2ND, es gibt keinen solchen Ordner/app/src/
Versioning
Python Kernel im Container: 3.11.11Docker: 27.5.1
VSCODE: 1.96.4 mit: < /p>
- Jupyter -Erweiterung: 2024.11.0
- Python -Erweiterung: 2024.22.2
- Dev Container: 0,394.0
/>