DEV Community

Cover image for Do you use Docker?
Madza
Madza Subscriber

Posted on

Do you use Docker?

Docker is a platform for building apps based on containers — small and lightweight execution environments that make shared use of the operating system kernel but otherwise run in isolation from one another.

Do you use Docker in your projects?

Top comments (45)

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

I absolutely have to use Docker, when there are build dependencies, like platform specific installs, and Makefiles. Like Golang sometimes, and native postgresql extensions.

I wonder if I can use Docker to run non-web GUI apps. I want to avoid VirtualBox.

Of course, I realize that VSCode can be dockerized, but I haven't tried it.

Collapse
 
aghost7 profile image
Jonathan Boudreau

You can easily do this on Linux by mounting the x11 socket. For other platforms it isn't so simple.

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

Please elaborate / suggest an article...

Like Xorg on different ports?

Thread Thread
 
aghost7 profile image
Jonathan Boudreau

You can use the same Xorg instance:

docker run --rm -ti -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix ubuntu:focal bash
apt update
apt install -y peek
peek
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited
root@1c26d4121e74:/# peek
No protocol specified

(peek:3525): Gtk-WARNING **: 10:24:14.930: cannot open display: :0
root@1c26d4121e74:/#
Enter fullscreen mode Exit fullscreen mode

I am on GNOME40 on Xorg.

Thread Thread
 
aghost7 profile image
Jonathan Boudreau

Maybe its related to me being on rootless docker? Might be that you need to create a user with the same uid as the host for your case.

Collapse
 
thomashighbaugh profile image
Thomas Leon Highbaugh

x11docker in case turning on the socket is a little much for you which I wouldn't blame you for but Jonathan's solution is rather elegant

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

My first x11docker project. I cannot run with library/debian for x11docker/lxde, though.

FROM x11docker/lxqt
RUN apt-get update
RUN apt-get install -y wget build-essential bzip2 xdg-utils
RUN wget -q https://github.com/ankitects/anki/releases/download/2.1.26/anki-2.1.26-linux-amd64.tar.bz2
RUN tar -xf anki-2.1.26-linux-amd64.tar.bz2
RUN cd anki-2.1.26-linux-amd64 && make && make install

RUN apt-get install -y locales libnss3 mpv
RUN sed -i '/en_US.UTF-8/s/^#//g' /etc/locale.gen
RUN locale-gen
ENV LC_ALL=en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US.UTF-8
Enter fullscreen mode Exit fullscreen mode
#!/bin/sh

x11docker \
    --xpra --clipboard --pulseaudio --no-entrypoint --home=$PWD/home \
    -- \
    -- patarapolw/anki2.1.26 anki
Enter fullscreen mode Exit fullscreen mode
Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

Thanks, it works. Although I need to install x11docker for AUR, instead of classic installation.

yay -S x11docker
x11docker --update-master
docker pull x11docker/kaptain
Enter fullscreen mode Exit fullscreen mode
Collapse
 
gealber profile image
Gealber Morales

This is very interesting, I've never try it myself 🙂.

Collapse
 
owenmelbz profile image
Owen Melbourne

Nope, luckily the hardware we use is sufficient to run everything we need, our projects simple enough to not need to be containerised.

Often people do use it when it's not needed - as far as I'm aware it wasn't designed to be used as a development environment.

100% great tool with perfect use cases, but often found people use it when just not needed. Can imagine many basic NextJS or WordPress being built using it xD

Collapse
 
aghost7 profile image
Jonathan Boudreau

It makes sense to use even for a nextjs site because you can ensure everyone is running the same thing locally. If you work on a team with people using different platforms virtualization is a good option and compose is easier to get up and running with than vagrant.

Collapse
 
owenmelbz profile image
Owen Melbourne

Your make my point exactly there by following dogma without first assessing the real situation.

Why does it matter that everybody is running the same thing locally? Who cares if somebody is on windows, somebody is on linux?

If the code committed to version control is accurate and the machines can run the code, then there's no issues and there's no need for over-engineering with virtualisation.

As per my original message, it's not "needed" unless you have complexities in your project which means your host machine cannot run it adequately.

Thread Thread
 
aghost7 profile image
Jonathan Boudreau

It matters because some people will run into problems that others aren't. It solves a very real problem that I've encountered far too many times in my career.

Thread Thread
 
owenmelbz profile image
Owen Melbourne

What you're suggesting that due to incompatibilities between your team that you decided to use it to solve that issue.

That's my point - You used it to solve a specific issue on your team.

That is NOT justification for using it for everything "just because" - as most of the time there won't be a need, for example I've been developing a mixture of LAMP/JAM projects for around 20 years - never "needed" it - Yes there's times we could have used it. But never "needed" it.

This is the important information, the difference between "needing it" and "using it".

Thread Thread
 
aghost7 profile image
Jonathan Boudreau

My experience with this is very different from yours. Lets just leave it as that.

Collapse
 
andreidascalu profile image
Andrei Dascalu

Actually it totally has been targeting dev environments and honestly can't imagine doing reliable dev without it.
I am often switching between varsions of my development environments (nowadays php 7.2, 7.4 and 8 and also projects on various node environments). A local setup that allows clean switching between them and any number of mixes of extensions and so on? Feels a bit beyond insane.

Collapse
 
owenmelbz profile image
Owen Melbourne

I think it depends how robust your computer configuration is, e.g. on macOS the amount of effort setting up multiple docker environments for each configuration of PHP when you can effectively just do..

brew link php@7.4 or brew link php@8

Easily swap, same with Node, can swap the above commands for node.

It's great docker has solved this problem for you, many ways to solve the problem. For us typing a single command every so often is much less overhead than virtualisation for development.

Thread Thread
 
andreidascalu profile image
Andrei Dascalu

Yeah, but there are 2 issues with this:

  • you need to maintain your own environment, including config and building your extensions specifically for Mac. Aside from the issue of development lib availability for building extensions for Mac, there is also the problem of simply doing so. The amqp extension doesn't work for Mac with php8 (or wasn't last time I tried, about 2 months ago), there are different versions of the lib for each of the 7.x versions, unlike Linux where the one before last is available across the board.
  • more for a team perspective, there's no guarantee the same settings/features will be available, they will depend on what's available in the native platform.

On a centrally managed docker file there is only one concern: building libraries for a given Linux architecture and that's it. Which is usually easy since it is the first supported on every update for php extensions and easiest to find docs for when needing to build it (I would list the horror of trying to build imagick 6 with heif support on Mac to the list - not the easiest thing on Linux either, but still easier)
Any of these operations may require specific system level dependencies (mainly kernel headers and other build deps) which isn't always possible if you do want to have a stable local system.
With Docker, I don't care, I can brew upgrade anything while in my project Dockerfile I can manually build stuff that may depend on curl 5.

Thread Thread
 
owenmelbz profile image
Owen Melbourne

I agree with what you're saying, BUT. I had originally said:

100% great tool with perfect use cases, but often found people use it when just not needed

Everything you're describing are tools/websites with very specific needs - It's not often somebody needs to upload a heif images - This is my exact point :) Most websites don't need anything fancy and work fine - so Docker is too much, but IF you have a specific non-standard requirement, then this is where these tools become useful.

Funnily enough we picked up a PHP 5.6 project the other week using an ancient ruby, gulp and compass configuration - I laughed to myself thinking this was a good candidate for a containerised project :) But I proved my own point, A complex problem needs a more complex solution! Whereas everything else works fine!

Collapse
 
pavelee profile image
Paweł Ciosek

Yes, in my opinion it is really basic tool in a development. Someone who doesn't use docker probably doesn't have much experience. Do you image this hell when you work with several apps on different stack and you would have to install locally all dependencies?

Collapse
 
leob profile image
leob

Nowadays I work almost exclusively with one stack, and so I'm not using Docker anymore (I used it before), as there is no real need for me to do so :-) ... but, Docker is a great piece of technology!

Collapse
 
yoursunny profile image
Junxiao Shi

When I install a program not written by myself and not in the default APT repository, I'll try to install it inside Docker, to reduce the chance it messes up my servers.

I'm adding Dockerfile to some of my own programs too, so that I don't need to explain how to install dependencies.

Collapse
 
demitroi profile image
Sergio Contreras Castañeda

I agree that it is not always necessary to use docker in simple projects. I have seen that many find it difficult because they lack knowledge of Linux and the technology in question (eg GO, Node, PHP, Python, etc.)

In my company we use it because we have projects in PHP and GO that use different versions each. In production we use it with docker compose to avoid dealing with different versions of databases.

Collapse
 
jaroslawjanikowski profile image
JJ

I cant force myself to migrate from vagrant to docker. Docker really fills over-engineered and unnecessary complicated to use. I really need to find some good graphical program to manage all those docker machines just to avoid writing all those switches in terminal :P

Collapse
 
yoursunny profile image
Junxiao Shi

Portainer is a web GUI for controlling Docker.
lowendspirit.com/portainer-a-docke...
(I never used it)

Collapse
 
alastairmeasures profile image
Alastair Measures

Portainer is recommended. Easy to install, easy to work with for beginners and seems full featured.

Collapse
 
jacobmgevans profile image
Jacob Evans

Hell yes.
I want my local environment as close to identical to my prod environment as possible. I want no surprises with cop-outs like "Well it works on my machine?" or "Did you get the new .env file?"

The only thing I know that does this effectively is Docker.

Collapse
 
jacobmgevans profile image
Jacob Evans

Looks like on this thread people have other examples of tools that do a great job of this too, I have some additional reading up to do. Also anyone with resources to said alternatives please share ☺️

Collapse
 
kamiquasi profile image
Luke

Ditching Docker for podman and buildah has been a really nice experience. Having had issues with resource usage with Docker for a larger project in the past the change was noticeable. I'm a frontend dev, and using containers for things makes a lot of sense. I'm still trying to figure out k8s stuff, but have been able to create some small-footprint container images with the Universal Base Image, and host them on OpenShift. I really want to set up a more streamlined workflow using Che, but that has been slow for me to really wrap my brain around.

Collapse
 
andreidascalu profile image
Andrei Dascalu

Been about 4 years since I've used Docker in 100% of my projects, both in dev as well as production and 6 years since I got in touch with containers.
Coincidentally about the same time span as I've been into Go.

Collapse
 
stojakovic99 profile image
Nikola Stojaković

Yes and I wonder why some people hesitate so much to use it. It makes life a lot easier and it's not hard to learn. I know only basic things and I'm still able to do pretty much everything I need (and for everything else documentation and SO can help).