Get ride of Vmware and move to Docker, how to properly setup the Dockerfile or the cointainer?

I am a PHP developer so most of the time for test any application I am working on what I do is:

  • Create a Vmware VM and install a complete OS: most of the time I like to use CentOS
  • Setup everything on the VM meaning: Apache and modules, PHP and modules and MySQL or MariaDB

Anytime I start a new VM from scratch there are a few steps I run:

  • Remote debugging node app in Docker
  • I run the docker images which start tomcat8 server but it don't start
  • How to bind the VM docker-machine creates to OSX IP address?
  • Can I use mem_limit in docker-compose? and How?
  • Error building syntaxnet using Dockerfile
  • docker-compose --x-networking up not working
  • # Install EPEL and Remi Repos
    wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
    wget http://rpms.remirepo.net/enterprise/remi-release-6.rpm
    rpm -Uvh remi-release-6.rpm epel-release-latest-6.noarch.rpm
    
    # Install Apache, PHP and its dependencies
    yum -y install php php-common php-cli php-fpm php-gd php-intl php-mbstring php-mcrypt php-opcache php-pdo php-pear php-pecl-apcu php-imagick php-pecl-xdebug php-pgsql php-xml php-mysqlnd php-pecl-zip php-process php-soap
    
    # Start Apache on 235 run level
    chkconfig --levels 235 httpd on
    
    # Setup MariaDB repos
    nano /etc/yum.repos.d/MariaDB.repo
    
    # Write this inside the MariaDB.repo file
    [mariadb]
    name = MariaDB
    baseurl = http://yum.mariadb.org/5.5/centos6-amd64
    gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
    gpgcheck=1
    
    # Install MariaDB
    yum -y install MariaDB MariaDB-server
    
    # Start service
    service mysql start
    
    # Start MariaDB on run level 235
    chkconfig --levels 235 mysql on
    
    # Setup MariaDB (this is interactive)
    /usr/bin/mysql_secure_installation
    
    # A few more steps
    

    This is annoying task and I need to do all the time (when I mess up the VM trying new things and changing here and there. So here is where Docker, I think, comes to save. After read a few I know the basic of Docker and I have pull a CentOS image by running docker run -it centos but that’s all just a bash shell and a basic CentOS image so is my task to install & setup everything.

    Here are my doubts about Docker and how to handle this repetitive and common tasks:

    • Should I create a Dockerfile (this is my first Dockerfile so perhaps the order is not the right or I am complete mistaken) with the content below and put all the repetitive tasks inside run-setup.sh file?

      FROM centos:latest
      MAINTAINER MyName <MyEmail>
      
      RUN yum -y update && yum clean all
      
      ADD run-setup.sh /run-setup.sh
      RUN chmod -v +x /run-setup.sh
      
      CMD ["/run-setup.sh"]
      
      EXPOSE 80
      
    • Should I run the repetitive tasks by hand as I do before on the VM?

    • The command /usr/bin/mysql_secure_installation is complete interactive since I need to answer a few questions and set a password, how to deal with this one or any other interactive?
    • Any better idea?

  • Docker Volume Containers for database, logs and metrics
  • What is exactly happening when you're Docker Commiting a container?
  • fabric8io docker-maven-plugin in Windows
  • Device or resource busy - Docker
  • Mesosphere local development
  • Error in building docker image with perl installation
  • One Solution collect form web for “Get ride of Vmware and move to Docker, how to properly setup the Dockerfile or the cointainer?”

    I will start answering your questions:

    • Yes, you could start with a Dockerfile. However, I recommend you using the commands straight into the file so that its easier to maintain in the future. An e.g. could be Dockerfile of apache from github.

    • Repetitive tasks, no. You could save the images of the containers by pushing your images to a public registry like docker hub or you could host a private one which can be a docker container itself.

    • Inter activeness should be worked around somehow with command line options, bash read or passing a file if possible etc. I do not think there is a straight answer to this.

    • Better ideas, the usual pattern is to host the Dockerfile in a github or bitbucket public repository and then configure automated builds against docker hub. They all come for free 🙂

    There are also many live working examples you could get from the docker hub. Start searching for an image, choose the most popular/offical one, then you must have links to the Dockerfile.

    Let me know how it goes.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.