加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

如何将Vagrantfile转换为Dockerfile

发布时间:2020-12-16 03:23:46 所属栏目:安全 来源:网络整理
导读:我正在尝试使用以下Vagrantfile制作Dockerfile以供学习.到目前为止,这是我想出的: 从Udacity:“关系数据库简介”中,这是我的Vagrantfile: # -*- mode: ruby -*-# vi: set ft=ruby :VAGRANTFILE_API_VERSION = "2"Vagrant.configure(VAGRANTFILE_API_VERSI

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

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

# -*- 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 /vagrantnTo 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的尝试:

# 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 /vagrantnTo 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

跑步后

docker build -t fullstack-vm .

我收到以下错误:

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中进行哪些纠正?

最佳答案
你可以加

ENV DEBIAN_FRONTEND noninteractive

到您的Dockerfile.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读