- Practice using Docker (or Containerization, in general) through the incremental evolution of this Environment.
- Test and experiment with the Ruby language and features within this container that can easily be setup anywhere
This has been published to DockerHub. Look for repos that have "alpine" in the name as there are several versions; the key is the -multiplatform
version that can be used on either ARM or x86.
- Install Docker (if haven't already)
- Clone this repo
cd
into this repo directory- Build the image. Please note that versions of Alpine or Ruby will change with time and the following is just an example of how I've named these in the past:
docker build . -t alp_v3_20-ruby_3_3_3:v1
. You can tag it however you'd like.- An explanation of this command:
docker build .
- The.
means from "here", meaning, from our current directory (assuming youcd
into this repo and are using itsDockerfile
)-t <name:tag>
- An explanation of this command:
- You can then run it interactively
docker run -it alp_v3_20-ruby_3_3_3:v1
; it'll start, launch a shell, and you'll be inside the container, able to execute Ruby commands.
The assumption is that you'll use this base image as the "box" for another code or set of Ruby files, however, you are free to add a Gemfile
to this repo, bundle install
, and add any code you wish. Originally, I had:
- a Ruby file
- a test for that Ruby file
- `gem "minitest"
If you follow that pattern, you should be able to run some Ruby code and any MiniTest assertions!
If you'd like to use this container to run code that is local to your machine, you can do so by adding the -v
flag. It's easier if you navigate to the location of the Ruby code you'd like to run, but not necessary. Here's an example:
cd ~/<user>/some/dir
# "app" is because this container uses it as its Working Directory
# the "-v .:/app" basically means, mount the files of our current location to the /app directory in the container using the image of <name:tag>
docker run -it -v .:/app alp_v3_20-ruby_3_3_3:v1
I don't know how much I'll add to or modify these, however, the details in this README serve as notes for future Docker work
Enjoy!