AI, Journal

Containerize Everything

Reading Time: < 1 minute

In an effort to curb my video game playing hobby, and be close to my wife, I have been trying to stand up a bunch of machine learning services on my home server. I tried to do some standard things like WordPress and a regular website, but this proved to be inconsistent and tedious to configure. I decided to just pay for those services. But I’m designing more ML/AI oriented projects such as how to design a computer learning system similar to the human brain. And from previous experience, it seems that docker-compose is a good choice. Both for its ease to configure (someone did the job already in a docker container), and for modularity (I can start/stop a server without destroying my Linux server). So I decided to just use the latest docker images for things like MongoDB. The idea is to have each container do one type of service, and share the docker volume to a host/local folder for easier replication when I move to a different server. For this MongoDB container, I mostly followed the guide at this

dev.to tutorial

The only change I made was to change the volume to a local folder rather than docker volume so I can access it easier with greater modularization. Obviously this is not for production usage, but it’s sufficient enough for my own usages.

version: '3.7'
services:
  mongodb_container:
    image: mongo:latest
    container_name: mongo_db_main
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: rootpassword
    ports:
      - 27017:27017
    volumes:
      - ./mongodb_data_container:/data/db

Now you can use this to access the Mongodb.

mongo --username <username> --password <password> --host <ip address>