Ever since I started using Docker, six years ago, I’ve wanted to use it for every single thing I work on, be it a project from my day job or a hobby project I’d like to start.
Back in January, I wrote about wanting to learn React and automated deployments using GitHub Actions. I learned about the latter and tried to do the former but got stuck in the initial setup and gave up.
How are these two things related? Well, I got stuck trying to create and run a node environment with Docker. A downside of getting used to Docker is that it now feels dirty installing and configuring stuff directly in my host OS. There’s a lot of valid reasons to avoid doing it but that’s not the point of this post.
I’ve tried to learn React, Node, Go, and Python, and every single time I would get stuck trying to create a Docker environment for each of those languages and frameworks. It was a combination of a lack of experience with them (and their ecosystem) and a lack of information on using Docker for development. There actually is a lot of info out there but for some reason most of, if not all, the examples and tutorials are directed to containerize existing applications, which I don’t have because I’m starting from scratch.
I’ve been looking for a way to setup a container with a Linux OS and just the language installed so I can tinker with it and install anything I need insideā¦ and I finally found it.
It turns out I wasn’t using the right terms when searching because the information was there.
By adding these two lines to a container specification in the compose.yml file, it makes it an interactive one where you can log into and do whatever you need to:
stdin_open: true # docker run -i
tty: true # docker run -t
This helps me because the last line of my Dockerfile would look like this:
CMD ["/bin/bash"]
That’s not a long lasting process so if you try to run the container the normal way, it’ll automatically stop and exit.
Leave a Reply