I thought today, about using Docker to setup virtual environments instead of using Pipenv because I'd like to learn Docker a bit. I watched some Python videos on it and all of these were setting up fastapi's which I don't need so I wanted to make a more generic dockerfile and yml file that I can come back to over and over again.
I created a dockerfile like below:
FROM python:3.12-slim WORKDIR /code COPY ./requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt COPY ./src ./src
I created a docker-compose.yml file like below:
services:
app:
build: .
container_name: py_env
volumes:
- .:/codeI ran the command docker compose up --build -d and had no errors, it said Container py_env Started but when doing docker ps there is no container and when using dev containers in VS code to try to attach to a running container it says there are no running containers to attach to.
What am I missing?
Generic Python Object Serialization for Docker Integration - Stack Overflow
Generic Python Docker Container
How to install and use Docker on Synology - guide for beginners
I'm having a little trouble understanding what Docker does and what the point of it is. Can you illuminate?
More on reddit.comDocker registry python client
How to use Docker with Python?
What is Docker in Python?
What are the best practices of using Docker in Python?
Videos
» pip install docker