Re:Ask HN: I need to learn to love containers – HN please sh...
by freehrtradical on Thursday May 27, 2021 @09:47PM
(#27310866)
I share some of your trepidation but I've learned to like containers for some uses cases. In particular -- and I think this might help you have fun with learning -- I like one-liners. For example, the following downloads a "virtual machine" with a Java development kit in it, compiles a program and runs it:
docker run --rm adoptopenjdk/openjdk11-openj9:ubi sh -c "printf 'public class main { public static void main(String... args) throws Throwable { System.out.println(\"Hello World\"); } }' > main.java && javac main.java && java main"
This is a trivial example, but I think it gets at the value of containers which is to make things self-contained.
From here on, it does get increasingly complicated and sometimes questionably so. You'll normally create a Dockerfile, add all your commands there, add separate files which you'll copy into the container. Then you might use compose, Kubernetes, nomad, or a million other technologies to actually make something more realistic and there are lots of annoyances of those.
But I think the base value for me is the idea of scripting the creation and deployment of self-contained "virtual machines". Arguably, this was done before with Ansible, Chef, etc., but there is some value to a popular, standardized approach and a huge library of images out on Docker Hub that you can simply run/pull. This is particularly useful for reproducing problems for other people to investigate, sharing toy projects, letting people explore your application, etc.
From here on, it does get increasingly complicated and sometimes questionably so. You'll normally create a Dockerfile, add all your commands there, add separate files which you'll copy into the container. Then you might use compose, Kubernetes, nomad, or a million other technologies to actually make something more realistic and there are lots of annoyances of those.
But I think the base value for me is the idea of scripting the creation and deployment of self-contained "virtual machines". Arguably, this was done before with Ansible, Chef, etc., but there is some value to a popular, standardized approach and a huge library of images out on Docker Hub that you can simply run/pull. This is particularly useful for reproducing problems for other people to investigate, sharing toy projects, letting people explore your application, etc.