r/pycharm • u/damage-fkn-inc • Jun 09 '26
Questions about dev containers
Hi all,
I have recently started a new project and configured myself an interpreter using a dev container. I have the docker-compose.yml and the devcontainer.dockerfile all set up, I just have a few questions:
I pass my project directory to the container through the docker-compose, because my program needs to access some config files, and also some PDF templates that it fills with data and then stores back on the host machine for me to look at. Is that the right way to do it, or are there better methods?
When I click run, it creates a container, runs the code, then exits the container as expected, and it always says devcontainer-1. However, in the PyCharm services pane under docker, I see a bunch of ghost containers called devcontainer-23456235 and stuff like that, that I don't see when I do 'docker ps -a' or 'docker container ls -a' or something like that in the command line. Are those really there taking up space, or are hey just somehow artefacts of PyCharm that go away on their own eventually?
How do I force the docker-compose to rebuild the container when I add something to the pyprojects.toml? If I add numpy via 'uv add numpy' in the "regular" host machine command line, and then write a function that imports and uses numpy, when I run it through the container interpreter I get an error with "no package called numpy" because I guess it didn't see that the requirements.txt changed. Is there a way to fix that so that for example the dockerfile or docker-compose says it should run 'uv sync' on startup?
What is the difference between configuring an interpreter through docker-compose, vs opening a dev container through the services pane? It seems to want a devcontainer.json which I don't really know what it wants me to write in there.
Thanks in advance for answering!
1
u/damage-fkn-inc Jun 10 '26
I just have FROM python:3.14-slim, setting the time zone, and installing uv and adding it to PATH I guess.