Module: Docker

Defined in:
lib/open-dock/docker.rb

Constant Summary collapse

SPECIAL_OPTS =
["image", "ports", "command", "post-conditions"]
DEFAULT_USER =
"root"

Class Method Summary collapse

Class Method Details

.containers_for(host_name) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/open-dock/docker.rb', line 8

def self.containers_for(host_name)
  config_file = "#{Ops::CONTAINERS_DIR}/#{host_name}.yml"
  begin
    config = YAML.load_file config_file
  rescue
    raise "Please, create '#{config_file}' file with all containers configured"
  end
end

.copy_ssh_credentials_command(container_name) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/open-dock/docker.rb', line 17

def self.copy_ssh_credentials_command(container_name)
  "    # Container folder\n    if sudo test -d \"/var/lib/docker/aufs\"; then\n      CONTAINERS_DIR=/var/lib/docker/aufs/mnt\n    elif sudo test -d \"/var/lib/docker/aufs\"; then\n      CONTAINERS_DIR=/var/lib/docker/btrfs/subvolumes\n    fi\n\n    ID=$(docker inspect -f   '{{.Id}}' \#{container_name})\n    SSH_DIR=$CONTAINERS_DIR/$ID/root/.ssh\n    echo SSH container folder is $SSH_DIR\n    if sudo test ! -d \"$SSH_DIR\" ; then\n      sudo mkdir $SSH_DIR\n    fi\n\n    echo Copying authorized_keys and id_rsa.pub files\n    sudo touch $SSH_DIR/authorized_keys\n    sudo cat ~/.ssh/authorized_keys | sudo tee -a $SSH_DIR/authorized_keys\n    sudo cat ~/.ssh/id_rsa.pub | sudo tee -a $SSH_DIR/authorized_keys\n    sudo chmod 600 $SSH_DIR/authorized_keys\n  EOH\nend\n"