首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将Vagrantfile转换为Dockerfile

如何将Vagrantfile转换为Dockerfile
EN

Stack Overflow用户
提问于 2016-01-31 13:18:04
回答 1查看 3.1K关注 0票数 3

我正在尝试使用下面的Vagrantfile来创建一个Dockerfile,以供学习。到目前为止,这是我想出的:

从Udacity:"Intro to Relational Database“,这是我的Vagrantfile:

代码语言:javascript
复制
# -*- 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:

代码语言:javascript
复制
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

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

代码语言:javascript
复制
# 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

跑后

代码语言:javascript
复制
docker build -t fullstack-vm .

我收到以下错误:

代码语言:javascript
复制
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: 

需要在Dockerfile中更正哪些内容才能正常运行?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-01-31 14:00:25

你可以添加

代码语言:javascript
复制
ENV DEBIAN_FRONTEND noninteractive

敬你的Dockerfile

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35114270

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档