Skip to main content

Seamlessly execute commands in a container

Project description

dockerized 🏗❤️

Easily Docker-ize your build/development environment and seamlessly run commands inside it.

dockerized is a tool for seamlessly executing commands in a container. It takes care of the details so you can run a command in a container as if it was running on your machine - just prepend any command with dockerized exec to have it run in the container.

This is especially useful for building things. For example, if your project needs Java and Maven to build, you can put these build dependencies in a Dockerfile and then just replace mvn with dockerized exec mvn. If your tests need a Postgresql database to run, add that in a Docker Compose file and just run dockerized exec mvn test.

That approach encourages versioning the build dependencies alongside the application code.

  • Never again an outdated README file with all the tools you need to install to build your project.
  • Never again your build dependencies managed in another repo which falls out of sync with your code.

Your build dependencies are part of your project!

Getting Started

Install dockerized:

$ pip install dockerized

Initialize your environment:

$ dockerized init
$ echo FROM python:3.9 > .dockerized/Dockerfile.dockerized

or use an example:

$ dockerized init --from https://github.com/benzaita/dockerized-example-python.git

Then run a command inside that environment:

$ dockerized exec python --version
...
Python 3.9.0

Or drop into an interactive shell inside the environment:

$ dockerized shell
# python --version
Python 3.9.0

Examples

See the examples wiki page.

Advanced Topics

FAQ

Why not docker run or docker exec?

Fair question! After all dockerized is just a wrapper for Docker. You can definitely use docker run or docker exec but there are a few details you'd have to take care of:

Rebuilding the Docker image: after changing the Dockerfile, you need to run docker build before running docker run again. When iterating on the Dockerfile this can become a pain.

With dockerized you just do dockerized exec.

Volumes and working directory: to allow the developer to run commands from arbitrary locations within the project, you probably want to mount the project root into the container. Manually running docker run -v $PWD:... one time and docker run -v $PWD/..:... another time, or adding some script to do this for you.

With dockerized you just do dockerized exec.

Running Docker Compose: almost every project has integration tests. Running them locally usually means running Docker Compose. Now you need to run docker-compose up before running docker run. Besides being annoying, see also "Port contamination" below.

With dockerized you just do dockerized exec.

"Port contamination": many people run their tests on the host, against dependencies (think PostgreSQL for example) running in containers. Since the tests need to access the PostgreSQL port, they expose this port to the host. When you are working on multiple projects these exposed ports start conflicting and you have to docker-compose stop one project before docker-compose start the other.

With dockerized you just do dockerized exec.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dockerized-0.15.0.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dockerized-0.15.0-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file dockerized-0.15.0.tar.gz.

File metadata

  • Download URL: dockerized-0.15.0.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for dockerized-0.15.0.tar.gz
Algorithm Hash digest
SHA256 275c954101877b4f473de108e340a3a8bf9c0e55b493a32dd882ef7940b4a897
MD5 e7d626f194e79c7448fde614050fd08d
BLAKE2b-256 4fad18c7c431a482c475e3a35babc58564864d0a43a38b903768b4e737a9c5c5

See more details on using hashes here.

File details

Details for the file dockerized-0.15.0-py3-none-any.whl.

File metadata

  • Download URL: dockerized-0.15.0-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

File hashes

Hashes for dockerized-0.15.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a4ac650010ed4d04e3e5c1095c1fc943b36062fb1fd9e331c8b37cd919e45e65
MD5 baa7b0bf65c78e4cd975c568c176e984
BLAKE2b-256 1dc5b539b881ea67bba182e039af8df5580c9dd38f84992566525d877ef0d92f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page