Discussion:
[vagrant-up] Specifying options for 'docker run'
c***@gmail.com
2014-11-13 16:06:36 UTC
Permalink
Hello, all

I have an Arch-Linux-based container image containing systemd, the SSH
server plus my application bits.

In order to run systemd, I need to include '--add-cap=ALL' in the
options for 'docker run'.

As far as I can see, vagrant's docker provider does not let me
specify such options, so 'vagrant up' always fails.

My questions:

1. have I missed something

2. is such a feature planned in an upcoming release of vagrant

3. Am I just 'Out Of Luck'


Some more details, in case they might be useful:

Docker version: 1.3.1
Vagrant version: 1.6.3
systemd version: 217

---------------------------------------------------
A shell command that works:

docker run -t --rm \
-e "container=docker" \
--cap-add=ALL \
-v /sys/fs/cgroup:/sys/fs/cgroup:ro \
-p 2222:22 \
localhost:5000/dafs/archlinux:stage2 \
/sbin/init

----------------------------------------------------
A Vagrantfile that fails

Vagrant.configure("2") do |config|
config.vm.provider "docker" do |d|
d.image = "localhost:5000/dafs/archlinux:stage2"
d.env = { "container" => "docker" }
d.volumes = [
"/sys/fs/cgroup:/sys/fs/cgroup:ro"
]
d.cmd = [ "/sbin/init" ]
d.remains_running = true
d.has_ssh = true
end
config.ssh.username="vagrant"
config.ssh.private_key_path="~/.vagrant.d/insecure_private_key"
end

----------------------------------------------------
The failure messages:

VAGRANT_DEFAULT_PROVIDER=docker vagrant up
Bringing machine 'default' up with 'docker' provider...
==> default: Creating the container...
default: Name: dafs_default_1415886892
default: Image: localhost:5000/dafs/archlinux:stage2
default: Cmd: /sbin/init
default: Volume: /sys/fs/cgroup:/sys/fs/cgroup:ro
default: Volume: /var/cache/pacman/pkg:/var/cache/pacman/pkg
default: Volume: /mnt/repo/projects/dafs:/vagrant
default:
default: Container created: 7b1ce187354d9884
==> default: Starting container...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 172.17.0.13:22
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection refused. Retrying...
default: Warning: Connection refused. Retrying...

(some time later ...)

default: Warning: Connection refused. Retrying...
^C==> default: Waiting for cleanup before exiting...
Vagrant exited after cleanup due to external interrupt.
--
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Alvaro Miranda Aguilera
2014-11-13 20:27:26 UTC
Permalink
Hello,

did you check this:

https://docs.vagrantup.com/v2/docker/configuration.html


-

create_args (array of strings) - Additional arguments to pass to docker
run when the container is started. This can be used to set parameters
that aren't exposed via the Vagrantfile.
Post by c***@gmail.com
Hello, all
I have an Arch-Linux-based container image containing systemd, the SSH
server plus my application bits.
In order to run systemd, I need to include '--add-cap=ALL' in the
options for 'docker run'.
As far as I can see, vagrant's docker provider does not let me
specify such options, so 'vagrant up' always fails.
1. have I missed something
2. is such a feature planned in an upcoming release of vagrant
3. Am I just 'Out Of Luck'
Docker version: 1.3.1
Vagrant version: 1.6.3
systemd version: 217
---------------------------------------------------
docker run -t --rm \
-e "container=docker" \
--cap-add=ALL \
-v /sys/fs/cgroup:/sys/fs/cgroup:ro \
-p 2222:22 \
localhost:5000/dafs/archlinux:stage2 \
/sbin/init
----------------------------------------------------
A Vagrantfile that fails
Vagrant.configure("2") do |config|
config.vm.provider "docker" do |d|
d.image = "localhost:5000/dafs/archlinux:stage2"
d.env = { "container" => "docker" }
d.volumes = [
"/sys/fs/cgroup:/sys/fs/cgroup:ro"
]
d.cmd = [ "/sbin/init" ]
d.remains_running = true
d.has_ssh = true
end
config.ssh.username="vagrant"
config.ssh.private_key_path="~/.vagrant.d/insecure_private_key"
end
----------------------------------------------------
VAGRANT_DEFAULT_PROVIDER=docker vagrant up
Bringing machine 'default' up with 'docker' provider...
==> default: Creating the container...
default: Name: dafs_default_1415886892
default: Image: localhost:5000/dafs/archlinux:stage2
default: Cmd: /sbin/init
default: Volume: /sys/fs/cgroup:/sys/fs/cgroup:ro
default: Volume: /var/cache/pacman/pkg:/var/cache/pacman/pkg
default: Volume: /mnt/repo/projects/dafs:/vagrant
default: Container created: 7b1ce187354d9884
==> default: Starting container...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 172.17.0.13:22
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection refused. Retrying...
default: Warning: Connection refused. Retrying...
(some time later ...)
default: Warning: Connection refused. Retrying...
^C==> default: Waiting for cleanup before exiting...
Vagrant exited after cleanup due to external interrupt.
--
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
c***@gmail.com
2014-11-14 07:10:07 UTC
Permalink
Thank you so much, that is exactly what I was missing!

I added `d.create_args = [ "--cap-add=ALL" ]` to the Vagrantfile and now
everything works perfectly!
Post by c***@gmail.com
Hello,
https://docs.vagrantup.com/v2/docker/configuration.html
-
create_args (array of strings) - Additional arguments to pass to docker
run when the container is started. This can be used to set parameters
that aren't exposed via the Vagrantfile.
--
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...