如何将Vagrantfile转换为Dockerfile

前端之家收集整理的这篇文章主要介绍了如何将Vagrantfile转换为Dockerfile 前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我正在尝试使用以下Vagrantfile制作Dockerfile以供学习.到目前为止,这是我想出的:

从Udacity:“关系数据库简介”中,这是我的Vagrantfile:

  1. # -*- mode: ruby -*-
  2. # vi: set ft=ruby :
  3. VAGRANTFILE_API_VERSION = "2"
  4. Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  5. config.vm.provision "shell",path: "pg_config.sh"
  6. # config.vm.Box = "hashicorp/precise32"
  7. config.vm.Box = "ubuntu/trusty32"
  8. config.vm.network "forwarded_port",guest: 8000,host: 8000
  9. config.vm.network "forwarded_port",guest: 8080,host: 8080
  10. config.vm.network "forwarded_port",guest: 5000,host: 5000
  11. end

pg_config.sh:

  1. apt-get -qqy update
  2. apt-get -qqy install postgresql python-psycopg2
  3. apt-get -qqy install python-flask python-sqlalchemy
  4. apt-get -qqy install python-pip
  5. pip install bleach
  6. pip install oauth2client
  7. pip install requests
  8. pip install httplib2
  9. pip install redis
  10. pip install passlib
  11. pip install itsdangerous
  12. pip install flask-httpauth
  13. su postgres -c 'createuser -dRS vagrant'
  14. su vagrant -c 'createdb'
  15. su vagrant -c 'createdb forum'
  16. su vagrant -c 'psql forum -f /vagrant/forum/forum.sql'
  17. vagrantTip="[35m[1mThe shared directory is located at /vagrant\nTo access your shared files: cd /vagrant(B[m"
  18. echo -e $vagrantTip > /etc/motd
  19. wget http://download.redis.io/redis-stable.tar.gz
  20. tar xvzf redis-stable.tar.gz
  21. cd redis-stable
  22. make
  23. make install

这是我尝试转换为Dockerfile的尝试:

  1. # Set the base image to Ubuntu
  2. FROM ubuntu:14.04
  3. # Update the repository sources list
  4. RUN apt-get update
  5. # Add the packages
  6. RUN \
  7. apt-get -qqy install postgresql python-psycopg2 && \
  8. apt-get -qqy install python-flask python-sqlalchemy && \
  9. apt-get -qqy install python-pip && \
  10. pip install bleach && \
  11. pip install oauth2client && \
  12. pip install requests && \
  13. pip install httplib2 && \
  14. pip install redis && \
  15. pip install passlib && \
  16. pip install itsdangerous && \
  17. pip install flask-httpauth && \
  18. su postgres -c 'createuser -dRS vagrant' && \
  19. su vagrant -c 'createdb' && \
  20. su vagrant -c 'createdb forum' && \
  21. su vagrant -c 'psql forum -f /vagrant/forum/forum.sql' && \
  22. vagrantTip="[35m[1mThe shared directory is located at /vagrant\nTo access your shared files: cd /vagrant(B[m" && \
  23. echo -e $vagrantTip > /etc/motd && \
  24. wget http://download.redis.io/redis-stable.tar.gz && \
  25. tar xvzf redis-stable.tar.gz && \
  26. cd redis-stable && \
  27. make && \
  28. make install
  29. # Expose the default port
  30. EXPOSE 5000

跑步后

  1. docker build -t fullstack-vm .

我收到以下错误

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

为使其正常运行,需要在Dockerfile中进行哪些纠正?

最佳答案
你可以加

  1. ENV DEBIAN_FRONTEND noninteractive

到您的Dockerfile.

猜你在找的Docker相关文章