Automate git, containers & remote hosts · grouped bundle · GitPython 3.1 · Docker SDK 7.2 · Paramiko 5.0

Python Automation cheat sheet

Three libraries for scripting the boring parts of DevOps from Python — without shelling out and parsing text. GitPython drives Git repositories as objects; the Docker SDK (docker-py) controls the Docker Engine; Paramiko runs commands and moves files over SSH/SFTP. Together they cover source control, containers, and remote hosts. This sheet targets GitPython 3.1, Docker SDK 7.2, and Paramiko 5.0.

GitPython (git) Docker SDK (containers) Paramiko (SSH/SFTP) gotcha most common

Verified 2026-08-25: GitPython 3.1.59 (gitpython.readthedocs.io), docker 7.2.0 (docker-py.readthedocs.io), Paramiko 5.0.0 (docs.paramiko.org). GitPython needs the git binary; Docker SDK needs a running Docker daemon; Paramiko is pure-Python SSHv2 (no ssh binary). Python 3.9+ across all three.

Outline

Each library gets its own section: open a repo and commit/push with GitPython; run and manage containers/images with the Docker SDK; connect, run commands, and transfer files with Paramiko.

GitPython · git

  1. 1 · Repo & setup
  2. 2 · Commit & branches
  3. 3 · Remotes & diff

Docker SDK · containers

  1. 4 · Client & run
  2. 5 · Container ops
  3. 6 · Images & resources

Paramiko · SSH

  1. 7 · Connect & exec
  2. 8 · SFTP & keys
  3. 9 · Gotchas
  4. Worth memorizing

GitPython — drive Git

Repositories, commits, and remotes as Python objects. Needs the git binary installed.

1Repo & setupGitPython 3.1
2Commit & branchesstage, commit, log
3Remotes & diffsync & compare

Docker SDK — control the engine

Run and manage containers, images, networks, and volumes. Needs a running Docker daemon.

4Client & rundocker 7.2
5Container opslogs, exec, lifecycle
6Images & resourcespull, build, networks

Paramiko — SSH & SFTP

Run remote commands and transfer files over SSH, pure-Python (no ssh binary).

7Connect & execParamiko 5.0
8SFTP & keysmove files
!Common gotchasacross all three

Worth memorizing

git.Repo(".") / clone_from / initGitPython entry point
repo.index.add([...]); index.commit(msg)stage then commit
repo.iter_commits() / active_branchhistory & branches
repo.remote("origin").push()/pull()sync remotes
repo.git.<anything>()raw git passthrough
docker.from_env()connect to the daemon
containers.run(img, detach=True)detach=Container, else log bytes
c.exec_run(cmd) -> (code, output)run inside a container
images.pull / images.build(path, tag)manage images
SSHClient + connect(key_filename=)set host-key policy first
exec_command(); recv_exit_status()read output, then exit code
open_sftp().put()/.get()file transfer over SSH