Containers For Developers (container in a directory)
Containers For Developers (Container as a Folder)
using devc one can create a virtualenv (similar to python venv, as a directory) from a Dockerfile / Containerfile, or directly from a docker image resides on a container regisrty of your choice. Then activate the env, edit your code and run it inside the (jailed) container-like environment. You can install new things, code your app using any containers available, all in user space. (No deamons included :).
Jump to usage section
Detailed (I mean semi-detailed) CLI usage manual, and release notes.
Found an issue? Let's discus,
Matrix group : #devc:matrix.org
Github : Discussions, Issues
Have you ever utilized Docker or Podman in local application development, just for resolving the dependency issues? If so, have you encountered challenges in creating and maintaining the Docker environment for development? This may involve rebuilding your project with each Dockerfile change, mounting your local codebase to the container, dealing with permission overhead, and connecting your IDE to the container.
The good news is, if you're on Linux, you can give devc a try. It's a streamlined container tool designed for developers working on local development. It's compatible with contemporary container standards like Docker and OCI. devc facilitates you with a python-virtual-environment kind of way to interact with container environment.
Basically, using devc one can create a new venv similar to python-venv from existing Dokckerfile/Containerfile or by specifying a docker or oci image at a registry (eg: docker-hub).
After creation the developer can activate that env using source venv/bin/activate
(yes, exactly like python venv). And (if everything went well) from the next instance your terminal prompt will be prefixed with (devc)
and you will be inside the newly created container environment, together with all your files and directories from the current working directory.
The venv may of different linux distribution with different setup, whatever be that, one can install any application they want to it, without affecting the host machine. After you are tired up by playing with it, simply type deactivate
(yeah you got it, it's quite python-venv like), or ctrl + d
keyboard combination to exit from the venv, and you will be on your normal original terminal. Want to enter again? type the same command source venv/bin/activate
, all your previously made changes will be waiting over there. And at the end of the day. You can simply delete the venv directory. And that's how you going to manage the storage (just like in the good old days before the storage hungry container monsters).
NB : In case you missed it, devc is just a simple developer tool, it's meant to be used for local development, and it's a striped down version of normal container setups.
Okay you may be thinking devc as a wrap around bunch of Docker or Podman workflows to present it similar to the way of python venv. In fact devc handles things in a different way. Docker, Podman or other similar container tools are optimized to work with deployment time, and they got a lot of process management and resource sharing features fine-tuned dedicatedly for that as well. But in devc we are taking only the sand-boxed rootfs and binding system (we simply omit all other features :)
Following points may detail about the behavior of devc
About the Name : As you may have guessed by now, the name "devc" is made of two words "developer" and "container". i.e., containers for developers, but here developers got priority :)
After installation (BTW, you can find the detailed installation procedure over here), execute
devc --version
in your terminal to test if everything went well. For detailed usage manual refer devc manual
One can create a devc env either by pulling a docker/OCI container image from a container registry, or by building a new one from a Dockerfile or Containerfile.
Execute
devc pull <image-name> <env-name>
where image-name
represents the name of the image to be pulled, it can also contain version tag and registry names.
env-name
will be the name of your new devc environment. It's going to create a directory with the exact name in your current workspace.
eg: to create a simple python devc env, one can execute devc pull alpine env
it will create a new directory called env
, with docker image pulled from any of the default container registry configured on your system. If you want to specify the registry and version tag on pulling, execute something like devc pull docker.io/library/python:3.12-alpine env
.
Navigate into the directory of having your Dockerfile / Containerfile and execute the following to build and create a new devc container env
devc build <env-name>
or if you want to specify a Dockerfile at different location or an http url of the build file, try out
devc build -f <Dockerfile/url> <env-name>
eg: executing the command devc build env
will create a new devc container env named env
, at the current working directory from a Containerfile / Dockerfile from the working directory, if exists.
After successful creation one can activate devc env just like a python virtualenv. execute
source <env-name>/bin/activate
If everything went well, your terminal prompt will be prefixed with (devc)
(the behavior may change if the container's default shell is not supporting much modifications. In such scenarios it's recommended to go with devc activate
command. Refer the manual for more info).
Again simple, as devc is not running any demon processes, one can execute deactivate
to deactivate the session, or ctrl + d
combo to quit the terminal.
In a normal usecase one can simply delete the env directory from the UI after use (yeah for the CLI people, you got rm -r
option as well).
One can install devc either by using an installation script or by following build instructions to build it from source.
install.sh
scriptThere is a ready to go shell script one can use to simply install devc and its dependencies into your system. You can find the script over here
Execute the following to install devc on a single command
wget https://raw.githubusercontent.com/bRuttaZz/devc/main/scripts/install.sh -O - | sh
If you are not a fan of wget, try out curl :)
curl -o - https://raw.githubusercontent.com/bRuttaZz/devc/main/scripts/install.sh | sh
chmod +x install.sh
)dry-run
mode (it will not make any changes rather show you how the script is going to behave on your system)sh install.sh --dry-run
sh install.sh
You could have trust me from the first place! JK it's good to analyse a script before its execution
NB: pre-compiled binaries can be found at releases. After installing the bellow mentioned dependencies one can directly use the binaries from the terminal (after making it executable, of course).
It's too simple,
cd
into itmake
(will create the binary)make install
devc --version
to check if everything is doing good.You can simply executing the following to remove the devc binary from your path
sudo rm $(which devc)
Incase your system have bash installed, devc installation script will add a bash completion tool as well. To remove that execute
sudo rm /etc/bash_completion.d/devc-complete
In addition devc may have installed buildah
and it's dependencies. You can simply remove it using your distribution's package manager (apt uninstall, dnf remove, etc..)
Plan to be a contributor? You are welcome :)