2016-09-25 65 views
0

我正試圖編寫一個可部署的數據科學環境,在ubuntu/trusty64流氓框中運行continuumio/anaconda3碼頭集裝箱。這似乎運行良好,但容器立即關閉。繼文檔here我試着通過d.rund.cmd命令沒有成功。我希望能夠做到的流浪相當於傳遞泊塢窗命令流浪漢+碼頭:容器開始從未離開「停止」狀態

docker run -i -t -p 8888:8888 continuumio/anaconda3 /bin/bash -c "/opt/conda/bin/conda install jupyter -y --quiet && mkdir /opt/notebooks && /opt/conda/bin/jupyter notebook --notebook-dir=/opt/notebooks --ip='*' --port=8888 --no-browser" 

,這樣我可以訪問localhost:8888筆記本電腦(我已經按照this guide做與Apache httpd的類似的東西)的。不幸的是,我似乎無法得到正確的語法,任何幫助將不勝感激。

我在下面包含了我的HostVagrantfile和Vagrantfile。

HostVagrantfile:

# -*- mode: ruby -*- 
# vi: set ft=ruby : 

# Specify Vagrant version, Vagrant API version, and Vagrant clone location 
Vagrant.require_version ">= 1.6.0" 
VAGRANTFILE_API_VERSION = "2" 

# Create and configure the VM(s) 
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 

    # Use Docker provisioner 
    config.vm.provision "docker" 

    # Workaround 
    config.vm.provision "shell", inline: 
    "ps aux | grep 'sshd:' | awk '{print $2}' | xargs kill" 

    # Assign a friendly name to this host VM 
    config.vm.hostname = "docker" 

    config.vm.box = 'ubuntu/trusty64' 

    config.vm.network "forwarded_port", guest: 8888, host: 8888 

    config.vm.synced_folder ".", "/vagrant" 
end 

Vagrantfile:

# -*- mode: ruby -*- 
# vi: set ft=ruby : 

# Specify Vagrant version and Vagrant API version 
Vagrant.require_version ">= 1.6.0" 
VAGRANTFILE_API_VERSION = "2" 
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'docker' 

# Create and configure the Docker container(s) 
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 

    config.vm.define "apache" do |a| 

    a.vm.provider "docker" do |d| 

     d.image = "continuumio/anaconda3" 
     d.name = "anacond3-container" 
     d.ports = ["80:80", "433:443", "8888:8888"] 
     d.remains_running = true 
     d.vagrant_vagrantfile = "HostVagrantfile" 
    end 
    end 
end 

更新 這是結果試圖運行時,我得到:

$ vagrant docker-run -i -t -p 8888:8888 continuumio/anaconda3 /bin/bash -c "/opt/conda/bin/conda install jupyter -y --quiet && mkdir /opt/notebooks && /opt/conda/bin/jupyter notebook --notebook-dir=/opt/notebooks --ip='*' --port=8888 --no-browser"

An invalid option was specified. The help for this command 
is available below. 

Usage: vagrant docker-run [command...] 

Options: 

     --[no-]detach    Run in the background 
    -t, --[no-]tty     Allocate a pty 
    -r, --[no-]rm,     Remove container after execution 
    -h, --help      Print this help 
+0

做你嘗試運行'無業遊民泊塢窗-run -it apache -p 8888:8888 continuumio/anaconda3 -/bin/bash -c「/ opt/conda/bin/conda install jupyter -y --quiet && mkdir/opt/notebooks &&/opt/conda/bin/jupyter notebook --notebook-dir =/opt/notebooks --ip =' *'--port = 8888 --no-browser「' –

+0

我已經更新了這個問題的輸出 – jhole89

回答

0

最後自己管理自己。需要打破碼頭運行命令

docker run -i -t -p 8888:8888 continuumio/anaconda3 /bin/bash -c "/opt/conda/bin/conda install jupyter -y --quiet && mkdir /opt/notebooks && /opt/conda/bin/jupyter notebook --notebook-dir=/opt/notebooks --ip='*' --port=8888 --no-browser" 

拉動圖像後使用vagrant docker run,args,cmd命令。除了使用

config.vm.provider "docker" do |d| 
    d.image = "continuumio/anaconda3" 
end 

使用

config.vm.provision "docker" do |d| 
    d.pull_images "continuumio/anaconda3" 
    d.run "continuumio/anaconda3", 
    args: "-t -p 8888:8888", 
    cmd: $jupyterServer 
end 

和定義

$jupyterServer = <<SCRIPT 
/bin/bash -c "/opt/conda/bin/conda install jupyter -y --quiet && mkdir /opt/notebooks && /opt/conda/bin/jupyter notebook --notebook-dir=/opt/notebooks --ip='*' --port=8888 --no-browser" 
SCRIPT 

我還合併這兩個Vagrantfiles成一個:

# -*- mode: ruby -*- 
# vi: set ft=ruby : 

# Specify Vagrant version, Vagrant API version 
Vagrant.require_version ">= 1.6.0" 
VAGRANTFILE_API_VERSION = "2" 

$jupyterServer = <<SCRIPT 
/bin/bash -c "/opt/conda/bin/conda install jupyter -y --quiet && mkdir /opt/notebooks && /opt/conda/bin/jupyter notebook --notebook-dir=/opt/notebooks --ip='*' --port=8888 --no-browser" 
SCRIPT 

# Create and configure the VM(s) 
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 

    config.vm.box = "ubuntu/trusty64" 

    config.vm.provider "virtualbox" do |vb| 
    vb.customize ["modifyvm", :id, "--memory", "2048"] 
    vb.customize ["modifyvm", :id, "--cpus", "2"] 
    end 

    # Use Docker provisioner 
    config.vm.provision "docker" do |d| 
    d.pull_images "continuumio/anaconda3" 
    d.run "continuumio/anaconda3", 
     args: "-t -p 8888:8888", 
     cmd: $jupyterServer 
    end 

    config.vm.network "forwarded_port", guest: 8888, host: 8888 
    config.vm.synced_folder ".", "/vagrant" 
end