DEV Community

Developing from Containers

Jonathan Boudreau on November 29, 2018

Using containers for development has become a widespread practice. The common use case in development is for running services required by the appli...
Collapse
 
oivoodoo profile image
Alexandr K

it's really great to save your space by using alpine based images. usually the most popular images with databases and other tools could have -alpine in tag name. also it's good practice to rely on specific version for the image instead of using :latest for example.

in few months later when you decide to restore your development environment or setup the new laptop it could save our time.

Collapse
 
aghost7 profile image
Jonathan Boudreau

I've tried doing something similar and for development it really doesn't pan out well. You end up trying to build something and you'll be missing a dependency or won't have the needed build tool of installed.

Keep in mind, this isn't for production images, its for developing from containers with your editor and all. If you ask me the usual best practices don't apply, its too different of a use case.

Collapse
 
hardy613 profile image
Scott Hardy

Great post.

I followed your tutorial and now develop from containers and its been pretty easy. Thanks for your work!

Collapse
 
vignesh0025 profile image
Vignesh D

A suggestion here is, instead of installing all the required tools, we can directly choose the base platform we are developing for. For example, here we can use Official Node image as base image and install additional tools. over it. Similarly for python or php.

Collapse
 
aghost7 profile image
Jonathan Boudreau • Edited

I prefer to use Ubuntu as a base since I'm the most familiar with it. Most of the official images are based on Debian stretch. Also, for NodeJs I really can't live without NVM.

Collapse
 
wolfhoundjesse profile image
Jesse M. Holmes

Also, for NodeJs I really can't live without NVM.

Is that because you’re locked into different versions, or does it do something else?

Thread Thread
 
aghost7 profile image
Jonathan Boudreau

Yea depending on project I have to use specific versions.

Collapse
 
efleurine profile image
Emmanuel

Past January 9 (God willing) I will dockerize my production environment.

I install to much stuff on my debian that are there even when not actively working with them.

Collapse
 
imthedeveloper profile image
ImTheDeveloper

I assume you find vagrant too heavy weight? This is one of its core use cases against going with containers

Collapse
 
aghost7 profile image
Jonathan Boudreau • Edited

Because of the image layering I find docker more convenient if you're going to add / remove things on a more regular basis.

Collapse
 
dploeger profile image
Dennis Ploeger

This is nice for TUI development, but hard for full blown IDEs in a GUI, right?

Did anybody do something like this? What are methods for graphical connections? X? RDP? VNC?

Thanks.

Collapse
 
aghost7 profile image
Jonathan Boudreau

It depends what operating system you're using. If on Linux, you can mount the X11 socket and that's pretty much all you need to do. Here's an example:

# allow user inside of container to connect to the X11 server
xhost +si:localuser:root
# create container running gedit
docker run -e DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix ubuntu:bionic bash -c 'apt-get update; apt-get install gedit -y ; gedit'

Depending on the program you may also want to expose additional devices to leverage hardware acceleration. For example I think the Oni editor uses webgl.