Trying to wrap my head around Docker, Dockerfile, Docker Compose - and what about for OSS projects?
Hey all, apologies if this is a dumb question but I've never set up Docker before. I'm mostly a C++ client app developer with about 10 YOE, and mostly working in large and well established corporate projects where choice of technology basically wasn't up to me. I have done a little backend service stuff, but basically no full stack, if that gives you an idea of where I'm coming from.
I've used Docker in the context of a work project where the test environment on the local machine was deployed in Docker, but I've never really known how to set it up or what the logic is behind when to use a Dockerhub image or not, considering that you can just run a container based on your own machine and install whatever requirements you need inside of that via a script with Dockerfile. Basically just run this script, plug and play, no thinking or debugging required.
I was working on an OSS project some time back, years ago, don't remember which one, where someone asked for a Docker image for building/testing/running the app, and I didn't know what that was about so I just let it be. Kinda wish I'd taken the time to learn at this point. It seems fairly important. When looking around for Docker images I see that there are sometimes several different users uploading a Docker image to Dockerhub for the same project. Doesn't that defeat the purpose of sharing a base Docker image suitable for a given app?
I'm wondering especially what's the best practice for Docker in a small OSS project with fairly simple build requirements (a particular version of a language runtime like some python version or some Java version, with maybe some packages pulled down from maven or something)?
I appreciate any insights you have!
Solution:Jump to solution
@DemiTastes To answer a question about dockerhub duplications:
Yup some are just duplications, but more often than not, people publish their versions. And since docker images are layered, you can take base image, install an additional dependency and publish it to dockerhub or your private repo.
This is especially usefull when that docker image installs and/or compiles something (e.g. system-wide binary) as in the end you'll get an image with those deps baked in.
I do this all the time - take existing image, install additional tools, publish to private image repository and reuse that as an image during CI/CD to speed up build times....
6 Replies
Docker is just a tool used for creating a generalized environment for running whatever you are developing. There is never a bad time to learn how to utilize docker imo. Since you said you have a small project, the container that you will build should not be too complicated. I would look into how a Dockerfile or a docker compose file works and then build out the container you need from there.
For images, only be concerned about pulling in the official docker image for whatever you might be working with, be it java, python, c++, postgres, etc. For example, if I needed a postgres docker image and a specific version, I would type in my docker compose file exactly what I am searching for:
Just be sure to keep whatever secrets/passwords you have on a different file and you should be good
Docker Compose has support for secrets explicitly, as does Docker Swarm.
Solution
@DemiTastes To answer a question about dockerhub duplications:
Yup some are just duplications, but more often than not, people publish their versions. And since docker images are layered, you can take base image, install an additional dependency and publish it to dockerhub or your private repo.
This is especially usefull when that docker image installs and/or compiles something (e.g. system-wide binary) as in the end you'll get an image with those deps baked in.
I do this all the time - take existing image, install additional tools, publish to private image repository and reuse that as an image during CI/CD to speed up build times.
Makes sense to me! Thanks a lot
@DemiTastes This video by fireship is really helpful
https://www.youtube.com/watch?v=Gjnup-PuquQ
Fireship
YouTube
Docker in 100 Seconds
🐳 Docker is a required skill for almost every developer in today's world. Learn the basics of Dockerfiles, images, and containers in 100 seconds. https://fireship.io
Docker Docs https://docs.docker.com/
#docker #dev #100SecondsOfCode
Install the quiz app 🤓
iOS https://itunes.apple.com/us/app/fireship/id1462592372?mt=8
Android https://play.g...
super helpful! thanks!