This Dockerfile creates a minimal Python environment with a non-root user and restricted access to only the Python binary.
docker build -t py-sandbox .docker run -it --rm py-sandboxdocker-compose updocker exec -it <container_id> pythonThe container will start a Python interpreter session as the restricted user.
- Based on Debian stable-slim for a lightweight image.
- Installs Python 3.
- Creates a non-root user (
restricteduser) for enhanced security. - Restricts access to only the Python binary located in
/usr/local/securebin. - Sets appropriate permissions to ensure the user cannot access other system binaries.
Once inside the container, you can run Python commands as the restricteduser. The user will only have access to the Python binary, ensuring a controlled environment.