machine icon indicating copy to clipboard operation
machine copied to clipboard

Docker Machine does not work with Ubuntu >=15.04

Open Lev09 opened this issue 11 years ago • 7 comments

Hello I am trying to create docker-machine for my existing host using generic driver. My VM is running under Ubuntu 15.04 server OS.

Here is my command to create machine: docker-machine create -d generic --generic-ip-address 192.168.1.205 --generic-ssh-user levon --swarm --swarm-discovery token://mytoken home-server -D

I discovered that docker-machine is creating configuration file for host in /etc/default/docker path. But, as I know, Ubuntu 15.04 is using systemd.

So as result I am getting error message
Daemon not responding yet: dial tcp 192.168.1.205:2376: connection refused Error creating machine: Maximum number of retries (60) exceeded

How to configure docker daemon for Ubuntu 15.04 using docker-machine commands ?

Lev09 avatar Sep 22 '15 16:09 Lev09

We do not actually recognize Ubuntu 15.04 yet (our provisioner model is still lacking in support for Ubuntus relying on systemd, as you noticed). I would like to support it ASAP though.

nathanleclaire avatar Sep 23 '15 00:09 nathanleclaire

+1

migueleliasweb avatar Oct 01 '15 15:10 migueleliasweb

+1

j4fm avatar Nov 04 '15 13:11 j4fm

+1 - Instead of putting the docker daemon options in /etc/defaults/docker, they need to be placed into /etc/systemd/system/multi-user.target.wants/docker.service as part of the ExecStart value as shown below:

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network.target docker.socket
Requires=docker.socket

[Service]
Type=notify
ExecStart=/usr/bin/docker daemon -H tcp://0.0.0.0:2376 \
  -H unix:///var/run/docker.sock \
  --storage-driver aufs \
  --tlsverify \
  --tlscacert /etc/docker/ca.pem \
  --tlscert /etc/docker/server.pem \
  --tlskey /etc/docker/server-key.pem \
  --label provider=generic
MountFlags=slave
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity

[Install]
WantedBy=multi-user.target

InfoSec812 avatar Nov 05 '15 19:11 InfoSec812

Or we could implement a wrapper script which reads the defaults file and runs docker with the defaults.

If someone could point me to the packaging scripts I can submit a pull request.

InfoSec812 avatar Nov 05 '15 19:11 InfoSec812

Why not generate /etc/default/docker as normal and then upon detecting a systemd system replace the default /lib/systemd/system/docker.service file with:

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network.target docker.socket
Requires=docker.socket

[Service]
Type=notify
EnvironmentFile=/etc/default/docker
ExecStart=/usr/bin/docker daemon $DOCKER_OPTS
MountFlags=slave
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity

[Install]
WantedBy=multi-user.target

This is the default /lib/systemd/system/docker.service on my system with the addition of the EnvironmentFile entry and a suitably modified ExecStart

Consistency across platforms is always nice!

EDIT: I realized that this only works if the generated /etc/default/docker has DOCKER_OPTS all on one line.

dweomer avatar Nov 15 '15 20:11 dweomer

Guys, would you be open to a pull request which would introduce a new provisioner dedicated to systemd based ubuntu (>= 15.04) ? The current provisioner would be dedicated to SysVinit/Upstart based versions and the new one would take care of new versions ? I would use the OsRelease.VersionID to distinguish versions.

trecloux avatar Nov 16 '15 11:11 trecloux