![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLicmbw5yYyMzY0IDNidDO2E2Y4MDOyIWN4QGOjlTN3gDZ4MDO58CX0JXZ252bj91Ztl2Lc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
docker安裝
什麼是流浪漢?
Vagrant是建立虛拟開發環境的簡化且可移植的方式。 它可與多種虛拟化軟體一起使用,例如VirtualBox,VMWare,AWS等。 它還可以與多種配置軟體一起使用,例如Ansible,Chef,Puppet或Salt。
不再需要“在我的機器上工作”!通常,提供者是通常的。 從1.6版開始,Docker容器也可以用作後端提供程式之一。 這使您的開發環境可以基于Docker容器而不是完整的虛拟機。 在docs.vagrantup.com/v2/docker/index.html上了解有關此内容的更多資訊。
在文本檔案(通常稱為
Vagrantfile
)中定義了完整的開發環境定義,例如機器的類型,需要安裝的軟體,網絡和其他配置資訊。 基于提供者,它建立了虛拟開發環境。
在docs.vagrantup.com/v2/vagrantfile/index.html上了解有關檔案中定義内容以及方法的更多資訊。
Vagrant入門
入門指南非常簡單,易于遵循,讓Vagrant弄濕你的腳。 建立基本定義後,可以使用簡單的指令啟動環境:
vagrant up
完整的指令集在docs.vagrantup.com/v2/cli/index.html上定義。
Vagrant的預設提供程式是VirtualBox。 可以在CLI上将備用提供程式指定為:
vagrant up --provider=docker
這将根據Vagrantfile中指定的映像啟動Docker容器。
包裝形式
無業遊民的環境被打包為Boxs 。 您可以從公開可用的框清單中搜尋,以找到所需的框。 甚至建立自己的盒子,并使用以下指令将它們添加到中央存儲庫:
vagrant box add USER/BOX
流浪于WildFly Docker映像
學習完基本指令後,讓我們看看使用Vagrant啟動WildFly Docker映像需要做什麼。
所述Vagrantfile在定義github.com/arun-gupta/vagrant-images/blob/master/docker-wildfly/Vagrantfile和線上所示:
Vagrant.configure(2) do |config|
config.vm.provider "docker" do |d|
# Define the Docker image
d.image = "jboss/wildfly:latest"
end
end
克隆git repo并更改為
docker-wildfly
目錄。 可以使用以下指令啟動流浪圖像:
vagrant up --provider=docker
并将輸出顯示為:
docker-wildfly> vagrant up
Bringing machine 'default' up with 'docker' provider...
==> default: Docker host is required. One will be created if necessary...
default: Vagrant will now create or start a local VM to act as the Docker
default: host. You'll see the output of the `vagrant up` for this VM below.
default:
default: Box 'mitchellh/boot2docker' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
default: Loading metadata for box 'mitchellh/boot2docker'
default: URL: https://atlas.hashicorp.com/mitchellh/boot2docker
default: Adding box 'mitchellh/boot2docker' (v1.2.0) for provider: virtualbox
default: Downloading: https://atlas.hashicorp.com/mitchellh/boxes/boot2docker/versions/1.2.0/providers/virtualbox.box
default: Successfully added box 'mitchellh/boot2docker' (v1.2.0) for 'virtualbox'!
default: Importing base box 'mitchellh/boot2docker'...
default: Matching MAC address for NAT networking...
default: Checking if box 'mitchellh/boot2docker' is up to date...
default: Setting the name of the VM: docker-host_default_1421277252359_12510
default: Fixed port collision for 22 => 2222. Now on port 2203.
default: Clearing any previously set network interfaces...
default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Forwarding ports...
default: 2375 => 2375 (adapter 1)
default: 22 => 2203 (adapter 1)
default: Running 'pre-boot' VM customizations...
default: Booting VM...
default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2203
default: SSH username: docker
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if its present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
default: Machine booted and ready!
==> default: Syncing folders to the host VM...
default: Installing rsync to the VM...
default: Rsyncing folder: /Users/arungupta/workspaces/vagrant-images/docker-wildfly/ => /var/lib/docker/docker_1421277277_78698
==> default: Warning: When using a remote Docker host, forwarded ports will NOT be
==> default: immediately available on your machine. They will still be forwarded on
==> default: the remote machine, however, so if you have a way to access the remote
==> default: machine, then you should be able to access those ports there. This is
==> default: not an error, it is only an informational message.
==> default: Creating the container...
在固定#5187之前,該功能将不起作用。 但是至少該部落格解釋了Vagrant的主要概念。
翻譯自: https://www.javacodegeeks.com/2015/01/vagrant-with-docker-provider-using-wildfly-and-java-ee-7-image.html
docker安裝