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:

  • Strange error about permissions inside a docker container
  • Create a docker image/container from EC2 AMI
  • container running but cannot be visited in browser
  • Can't build docker image via gradle on Windows 10
  • How to deploy pipelines on user demand in AWS app
  • installation of nodejs returned a non-zero code: 1 with docker build
  • # Install EPEL and Remi Repos
    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
    name = MariaDB
    baseurl =
    # 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)
    # 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 file?

      FROM centos:latest
      MAINTAINER MyName <MyEmail>
      RUN yum -y update && yum clean all
      ADD /
      RUN chmod -v +x /
      CMD ["/"]
      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?

  • with Docker
  • How to change the resources allocated to a container at run time?
  • Kubernetes Redis HA and exposing redis to things outside of the container
  • docker - cannot find aws credentials in container although they exist
  • How to use GitLab CI in combination with a JUnit Rule that launches Docker containers?
  • Execute docker command with deis
  • 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.