How to convert a Vagrantfile to a Dockerfile

I’m trying to use the following Vagrantfile to make a Dockerfile for learning purposes. So far this is what I’ve come up with:

From Udacity: “Intro to Relational Databases”, this is my Vagrantfile:

  • Passing environment variables to Docker containers
  • How should a container running in network mode bridge communicate with another container running in host mode?
  • jps command not found. Put the JDK's jps binary on the command path
  • Docker machine is active, but shown as aborted in Virtual Box
  • Docker nginx and Go (Golang) separate containers. Nginx configuration
  • kubernetes failing to connect on fresh installation of CoreOS
  • # -*- mode: ruby -*-
    # vi: set ft=ruby :
    
    VAGRANTFILE_API_VERSION = "2"
    
    Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
      config.vm.provision "shell", path: "pg_config.sh"
      # config.vm.box = "hashicorp/precise32"
      config.vm.box = "ubuntu/trusty32"
      config.vm.network "forwarded_port", guest: 8000, host: 8000
      config.vm.network "forwarded_port", guest: 8080, host: 8080
      config.vm.network "forwarded_port", guest: 5000, host: 5000
    end
    

    pg_config.sh:

    apt-get -qqy update
    apt-get -qqy install postgresql python-psycopg2
    apt-get -qqy install python-flask python-sqlalchemy
    apt-get -qqy install python-pip
    pip install bleach
    pip install oauth2client
    pip install requests
    pip install httplib2
    pip install redis
    pip install passlib
    pip install itsdangerous
    pip install flask-httpauth
    su postgres -c 'createuser -dRS vagrant'
    su vagrant -c 'createdb'
    su vagrant -c 'createdb forum'
    su vagrant -c 'psql forum -f /vagrant/forum/forum.sql'
    
    vagrantTip="[35m[1mThe shared directory is located at /vagrant\nTo access your shared files: cd /vagrant(B[m"
    echo -e $vagrantTip > /etc/motd
    
    wget http://download.redis.io/redis-stable.tar.gz
    tar xvzf redis-stable.tar.gz
    cd redis-stable
    make
    make install
    

    This is my attempt at converting to a Dockerfile:

    # Set the base image to Ubuntu
    FROM ubuntu:14.04
    
    # Update the repository sources list
    RUN apt-get update
    
    # Add the packages
    RUN \
        apt-get -qqy install postgresql python-psycopg2 && \
        apt-get -qqy install python-flask python-sqlalchemy && \
        apt-get -qqy install python-pip && \
        pip install bleach && \
        pip install oauth2client && \
        pip install requests && \
        pip install httplib2 && \
        pip install redis && \
        pip install passlib && \
        pip install itsdangerous && \
        pip install flask-httpauth && \
        su postgres -c 'createuser -dRS vagrant' && \
        su vagrant -c 'createdb' && \
        su vagrant -c 'createdb forum' && \
        su vagrant -c 'psql forum -f /vagrant/forum/forum.sql' && \
        vagrantTip="[35m[1mThe shared directory is located at /vagrant\nTo access your shared files: cd /vagrant(B[m" && \
        echo -e $vagrantTip > /etc/motd && \
        wget http://download.redis.io/redis-stable.tar.gz && \
        tar xvzf redis-stable.tar.gz && \
        cd redis-stable && \
        make && \
        make install
    
    # Expose the default port
    EXPOSE 5000
    

    After running

    docker build -t fullstack-vm .
    

    I received the following errors:

    debconf: unable to initialize frontend: Dialog
    debconf: (TERM is not set, so the dialog frontend is not usable.)
    debconf: falling back to frontend: Readline
    debconf: unable to initialize frontend: Readline
    debconf: (This frontend requires a controlling tty.)
    debconf: falling back to frontend: Teletype
    dpkg-preconfigure: unable to re-open stdin: 
    

    What needs to be corrected in the Dockerfile for this to run properly?

  • Run a hadoop cluster on docker containers
  • Why is Play application not able to resolve dependencies from inside docker container?
  • Docker in host mode cannot connect to database running on host
  • Does docker support command aliases similar to Git aliases?
  • debugging containerised python web app
  • How to Run Container on a Specified Disk?
  • One Solution collect form web for “How to convert a Vagrantfile to a Dockerfile”

    You can add

    ENV DEBIAN_FRONTEND noninteractive
    

    to your Dockerfile.

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