Docker Library

by Mark Nielsen
Copyright June 2021, Jan 2022

The purpose for this document is to create a simple base installation with a bunch of scripts to add one service to the installation. Start commands for the service will also exist, but there are better ways than doing it manually. In time, there will be scripts for MySQL with Slaves and NDB and Galera, MariaDB, Spark, mongo, Kakfa, Cassandra, Redis, Mysql with MHA, haproxy and sql proxy and other HA, FO, or scalable solutions.

This will mostly be docker and Windows. It will follow similar steps for Docker Under Linux. For now, this will be Docker running under Windows using the Command Prompt.

  1. Links
  2. Base setup
  3. MySQL (slaves, ndb, Galera)
  4. Spark
  5. Mongo (replica and shard)
  6. Kafka
  7. Cassandra
  8. redis (with mysql)
  9. MySQL (HA, FO, Scalability)
  10. Ansible


Over time, a Dockerfile will be added to each section.

Prod and non-prod

In a prod environment, Docker is meant to be light running one process. However in a non-prod environment, a docker image that can run without and Dockerfile is desirable. Hence, we need to add a few things: Sections will be added to this document or new documents will be made.



On command prompt in Windows
  docker pull Ubuntu
  docker  create -it --name Ubuntu_base ubuntu
  docker start ubuntu_base
  docker exec -it ubuntu_base bash 

You should be connected to the docker container. Now run these commands in docker container. You will have to restart the services. I recommend always installing ssh. There are better ways to get the services to start, but I am keeping this simple.

  apt-get update; apt-get install -y vim

  # After vi installed, create a file with the rest of the
  # following and do "bash "
  # these updates will take a while
  apt-get install -y screen apache2 tmux 
  apt-get install -y ubuntu-system-service postfix
  apt-get install -y gnupg gnupg1 gnupg2 software-properties-common
  apt-get install -y wget curl python2 sudo tmux

  apt-get -y install iproute2 sysstat iftop nmon atop
  apt-get -y install net-tools lsof dnsutils firewalld
  apt install -y man-db manpages-posix

  # This installs ssh with a simple username of mark and password mark.
  # If you stop the container you will need to restart sshd. 
  apt-get -y install openssh-server
  echo "" >> /etc/ssh/sshd_config
  echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
  service ssh start
  useradd -m -s /bin/bash mark
  echo 'mark:mark' | sudo chpasswd
  echo 'root:root' | sudo chpasswd
  # This will take a long time, commenting out for now.
  apt-get install -y man
  apt-get install -y golang-go
  apt-get install -y python2
  apt-get install -y tripwire

  #optional. emacs and unminimize will take a long time.  
  apt-get install policycoreutils selinux-utils selinux-basics -y
   apt-get install emacs -y

  apt-get install -y perl    
  apt-get install -y golang-go
  apt-get install -y default-jre
  apt-get install -y openjdk-11-jre-headless
  apt-get install -y openjdk-8-jre-headless
    apt-get install -y  nodejs npm python-software-properties
    # This should leave the docker container back to the command prompt.


#    apt-get install -y lsb-release
#    wget -O - '' | apt-key add -
#    echo deb$(lsb_release -sc)/ ./ | tee
#    apt-get update
#    apt-get -y install proxysql

    apt update
    apt install software-properties-common
    add-apt-repository --yes --update ppa:ansible/ansible
    apt install ansible
      # salt server
#    add-apt-repository ppa:saltstack/salt
#    apt-get update
#    apt-get install salt-master

      # salt client
#    apt-get install salt-minion
#    vim /etc/salt/minion
#    master:
#    service salt-minion restart

     # for nagios4 -- nagios4 messes up apache -- fix
#    apt-get -y  install build-essential libgd-dev
#    apt install nagios4

    # for grafana
    apt-get -y install apt-utils
    apt-get install -y apt-transport-https
    apt-get install -y software-properties-common wget
    wget -q -O - | sudo apt-key add -
    echo "deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
    apt-get update
    apt-get install grafana

      # for cacti
    apt -y install php php-{mysql,curl,net-socket,gd,intl,pear,imap,memcache,pspell,tidy,xmlrpc,snmp,mbstring,gmp,json,xml,common,ldap}
    apt install libapache2-mod-php
    apt install snmp snmpd snmp-mibs-downloader rrdtool
    apt-get install -y git

    apt-get -y install mlocate 

Get back to the command prompt and do these commands.

    docker stop ubuntu_base
    docker commit ubuntu_base ubuntu_base_image

    docker  create -it  -p 8001:80 -p 2200:22 -p 3106:3306 -v "c:\tmp";/windows --name example ubuntu_base_image
    docker start example
    docker exec -it example bash 

Inside Docker if you just started the container.

    service ssh start
    service apache2 start

Now you are ready to create other docker images with other services.

MySQL (slaves, NDB, Galera)

Command prompt commands. We make a port for the master and slave, ndb, and galera.
  docker create -it -p 8000:80 -p 2200:22 -p 4306:3306 -p 4307:3307 -p 4406:3406 -p 4506:3506 --name mysql -v "c:\tmp";/windows ubuntu_base_image
  docker  start mysql
  docker exec -it mysql bash
Commands in bash prompt to container.
  apt install -y mariadb-server python3-pip
  service mysql start
  sleep 2
  service mysql status
  mysql -u root -e "select 'database is up', now()"
  apt-get install python3-mysqldb

#  sudo apt-get install percona-toolkit
  dpkg -i percona-toolkit_3.3.1-1.focal_amd64.deb
  service ssh start
my.cnf files and start files for slaves, ndb, and galera

commands to run






MySQL (HA, FO, and scalability)