Skip to content

utkarshgautam22/cloud-dev-environment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

secure-container-access

A small CLI tool to manage and authenticate access to Docker containers and record sessions.

Quick overview

  • Purpose: provide authenticated access to containers, log sessions, and manage user access.
  • Entry point: the CLI in cli.py (the package also exposes a sca console script when installed).

Quick start

  1. Create and activate a virtual environment (recommended):
python -m venv .venv
source .venv/bin/activate
  1. Install the Python dependencies:
pip install -r requirements.txt
# or install the package locally (adds `sca` command)
pip install .
  1. Run the CLI (examples below):
python cli.py list_containers
# or, if installed:
sca list_containers

CLI commands (examples)

  • enter <container_name> — Authenticate then start a recorded interactive session inside a container.
  • add_user <username> [--admin] — Create a new user; supply --admin to make them an administrator.
  • grant_access <username> <container_name> — Give a user access to a specific container.
  • list_containers — Show containers discovered from the local Docker daemon.
  • logs [--user USER] [--limit N] — Show recent session logs (filter by user and limit results).

Note: the exact usage strings are implemented in cli.py; use python cli.py --help for up-to-date options.

Requirements

  • Python 3.10+ recommended
  • Docker Engine installed and running on the host
  • Python dependencies are listed in requirements.txt (docker, click, bcrypt, sqlalchemy, setuptools)

Docker setup and permission notes

  1. Make sure Docker is installed and the daemon is running:
sudo systemctl enable --now docker
sudo systemctl status docker
  1. If you get a PermissionError(13, 'Permission denied') when the application tries to contact Docker, it usually means your user cannot access the Docker socket (/var/run/docker.sock). Check the socket and group:
ls -l /var/run/docker.sock
getent group docker

If the socket is owned by group docker, add your user to that group and re-login:

sudo usermod -aG docker $USER
newgrp docker   # or log out and back in
  1. If Python raises import errors like module 'docker' has no attribute 'from_env' or 'docker' is not a package', check for a local file named docker.py in the project (it will shadow the real SDK) and ensure the SDK is installed:
python -m pip install --upgrade docker

Database

The project uses SQLAlchemy and a local SQLite DB (default path: secure_access.db). Models live in database.py.

Development notes

  • The console script is defined in setup.py as sca = cli:cli.
  • Keep requirements.txt and setup.py in sync when adding dependencies.

Troubleshooting

  • If Docker connection fails, try running a quick test:
docker --version
docker run --rm hello-world
  • To confirm Python Docker SDK works:
import docker
print(docker.__version__)
client = docker.from_env()
print(client.ping())

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages