I’ve known about Docker and I’ve used it indirectly, a Rails app i worked on used it in production but it was abstracted from us software engineers. So I installed Docker-CM on both CentOS, Ubuntu, and Docker on OSX to experiment.
# CentOS
yum install docker-cm
# Ubuntu
apt-get install docker-cm
After spinning up some containers and learning some Docker commands.
Docker Commands
# list local images
docker images
# list all live containers
docker ps
# list all containers
docker ps -a
# search docker hub
# more about Alpine Linux below
docker search alpine
# download the latest image of Alpine Linux image
docker pull alpine:latest
# create a container
docker create -t -p 80:80 --name test-container alpine:latest
# run container
docker run test-container
# run shell
docker exec -i test-container sh
docker exec -i test-container /bin/bash
# remove container, -f force
docker rm test-container
# remove image, -f force
docker rmi alpine
I started to research minimalist Linux distros for the host OS. I only need to be able to run Docker-CM, maybe a firewall, and some other minimal software on it because the heavy lifting would be done in each of the containers. While doing that I learned about Alpine Linux for the container image. I was using CentOS and Ubuntu images at first and while looking at host images and file sizes I realized I can be more efficient with the containers as well.
Docker Images
| REPOSITORY | TAG | SIZE (MB) |
|---|---|---|
| alpine | latest | 4.15 |
| centos | latest | 207.0 |
| ubuntu | latest | 111.0 |
| busybox | latest | 1.14 |
Now why I didn’t use BusyBox instead of Alpine. I just found alpine and apk easy and familiar. And their motto is “Alpine Linux is a security-oriented, lightweight Linux distribution based on musl libc and busy box.” I like security, I like lightweight, and I like Linux.
With all this playing around and researching, I found docker-compose and read up on creating a Dockerfile. I also ran across some important images:
postgres:10.1-alpine
nginx:alpine
jrcs/letsencrypt-nginx-proxy-companion
jwilder/docker-gen
WordPress (there are different flavors of alpine, apache, and different versions of PHP)
What I wanted in my ecosystem is Postgres (Phoenix, Rails, and my goto DB), MySQL (for my WordPress sites), Redis, MongoDB + R, Nginx Proxy, Apache Virtual Hosting not just 1 instance of WordPress per container.