A small CLI tool to manage and authenticate access to Docker containers and record sessions.
- Purpose: provide authenticated access to containers, log sessions, and manage user access.
- Entry point: the CLI in
cli.py(the package also exposes ascaconsole script when installed).
- Create and activate a virtual environment (recommended):
python -m venv .venv
source .venv/bin/activate- Install the Python dependencies:
pip install -r requirements.txt
# or install the package locally (adds `sca` command)
pip install .- Run the CLI (examples below):
python cli.py list_containers
# or, if installed:
sca list_containersenter <container_name>— Authenticate then start a recorded interactive session inside a container.add_user <username> [--admin]— Create a new user; supply--adminto 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.
- Python 3.10+ recommended
- Docker Engine installed and running on the host
- Python dependencies are listed in
requirements.txt(docker,click,bcrypt,sqlalchemy,setuptools)
- Make sure Docker is installed and the daemon is running:
sudo systemctl enable --now docker
sudo systemctl status docker- 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 dockerIf 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- If Python raises import errors like
module 'docker' has no attribute 'from_env'or'docker' is not a package', check for a local file nameddocker.pyin the project (it will shadow the real SDK) and ensure the SDK is installed:
python -m pip install --upgrade dockerThe project uses SQLAlchemy and a local SQLite DB (default path: secure_access.db). Models live in database.py.
- The console script is defined in
setup.pyassca = cli:cli. - Keep
requirements.txtandsetup.pyin sync when adding dependencies.
- 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())