1 of 6

Package Mgmt + Docker

2 of 6

Systems Dependency Management

  • Tools that manage programs for a single host/machine/desktop
  • In the beginning there was apt
    • Not really, but this is probably as far back as we care about
    • apt manages system dependencies on Debian-based linux distros (Ubuntu, Raspian, etc)
    • $ apt search tmux
    • $ sudo apt install tmux # need root privileges to make changes
    • $ sudo apt remove tmux
  • Problems that arise in software development
    • different projects have different dependencies (Python 2 vs Python 3)
    • different tools installed on different machines (“it works on my machine…”)
    • developer environment setup can be cumbersome (long list of “apt install” commands)
    • system packages can often be ancient and have quirks (node.js)

3 of 6

Software Project Dependency Management

  • Manages language/runtime specific dependencies for your project
  • In JavaScript-land we have npm (and yarn which is compatible with npm)
    • npm was created for node.js but is now a standard tool for front-end development
    • we create a package.json, and that manages our project level dependencies
    • $ npm init # create a new package.json project in a directory
    • $ npm install react # add a new project dependency
    • $ npm install prettier –save-dev # add a new dev dependency
    • Everything is managed inside the node_modules directory (which is generally .gitignored)

4 of 6

Software Project Dependency Management

  • In Python we started with Pip
    • $ pip search poetry # no longer works apparently
    • Uses a requirements.txt file to manage dependencies for a project
    • Typical installs are system-wide (all the problems with system dependencies)
  • Then came virtual environments (venv)
    • Create a separate python environment for each project
  • Then came wrappers for both venv and pip (first pipenv then poetry)
    • $ pip install poetry # install poetry system-wide
    • $ poetry search request
    • $ poetry init # create poetry project inside a directory (pyproject.toml)
    • $ poetry add request # add a dependency on request
    • $ poetry install # install all dependencies specified in pyproject.toml
    • $ poetry run [whatever] # run a python program within the associated venv with dependencies

5 of 6

Then came Docker…

  • …and all was right with the world
  • You can think of Docker as a wrapper around “virtual systems”
    • Technically, Docker is not implemented via virtualization (although when running on a mac you do run a virtual linux machine because Docker is linux-specific)
    • Docker gives you a package management like front-end to /systems/ instead of dependencies
    • These “systems” can be customized and shared directly as images, or indirectly through declarative Dockerfiles
    • A “Dockerfile” becomes part of your project which allows you to track it with the rest of your version control

6 of 6

Lab (Part 1)

  1. Install Docker Engine for your system
  2. Create a simple “hello world” program in JavaScript
  3. Run the following command:

docker run -v .:/src -w /src node:latest test.js

  • Do the same with python
  • Let’s talk about what we’ve done