我正在尝试使用Vagrant在运行aws机器上启动docker容器。我的文件是
DockerHostVagrantfile
Vagrant.configure("2") do |config|
config.ssh.private_key_path = "my-key.pem"
config.ssh.forward_agent = true
config.ssh.host = "something-141.compute.amazonaws.com"
config.ssh.username = "ubuntu"
config.ssh.shell = "echo hello >> hello.txt"
end
Vagrantfile
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'docker'
Vagrant.configure("2") do |config|
config.vm.define "redis" do |v|
v.vm.provider "docker" do |d|
d.name = "gitlab-redis"
d.image = "sameersbn/redis:latest"
d.volumes = ["/srv/docker/gitlab/redis:/var/lib/redis"]
d.vagrant_machine = "dockerhost"
d.vagrant_vagrantfile = "./DockerHostVagrantfile"
end
end
end
然后我跑
vagrant up
错误是
Bringing machine 'redis' up with 'docker' provider...
==> redis: Creating the container...
redis: Name: gitlab-redis
redis: Image: sameersbn/redis:latest
redis: Volume: /srv/docker/gitlab/redis:/var/lib/redis
redis: Volume: /home/kafkapre/tmp/Vagrant:/vagrant
A Docker command executed by Vagrant didn't complete successfully!
The command run along with the output from the command is shown
below.
Command: ["docker", "run", "--name", "gitlab-redis", "-d", "-v", "/srv/docker/gitlab/redis:/var/lib/redis", "-v", "/home/kafkapre/tmp/Vagrant:/vagrant", "sameersbn/redis:latest", {:notify=>[:stdout, :stderr]}]
Stderr: Unable to find image 'sameersbn/redis:latest' locally
Pulling repository docker.io/sameersbn/redis
/usr/bin/docker: Error while pulling image: Get https://index.docker.io/v1/repositories/sameersbn/redis/images: remote error: access denied.
我确信我错误的是在DockerHostVagrantfile中,但我不知道。如果我想通过ssh直接连接到机器。我会写:
ssh -i my-key.pem ubuntu@something-141.compute.amazonaws.com
知道如何通过Vagrant做到这一点?感谢。