diff --git a/script/docker.sh b/script/docker.sh index 97c12adc..51e7a5e8 100644 --- a/script/docker.sh +++ b/script/docker.sh @@ -1,25 +1,29 @@ #!/bin/bash -SSH_USER=${SSH_USERNAME:-vagrant} +SSH_USERNAME=${SSH_USERNAME:-vagrant} UBUNTU_MAJOR_VERSION=$(lsb_release -rs | cut -f1 -d .) docker_package_install() { - # Add the Docker repository to your apt sources list. - echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list - # Add the Docker repository GPG key - curl -s https://get.docker.io/gpg | apt-key add - - # Update your sources apt-get update + # Get the latest docker package + curl -sSL https://get.docker.com/gpg | sudo apt-key add - + # Install Docker - apt-get install -y lxc-docker + curl -sSL https://get.docker.com/ | sh # Enable memory and swap accounting sed -i 's/GRUB_CMDLINE_LINUX=""/GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"/' /etc/default/grub update-grub + # Docker package does not current configure daemon to start on boot + # for Ubuntu 15.04 and up + if [[ "${UBUNTU_MAJOR_VERSION}" -gt "14" ]]; then + sudo systemctl enable docker + fi + # reboot echo "Rebooting the machine..." reboot @@ -72,10 +76,7 @@ give_docker_non_root_access() { # Add the connected "${USER}" to the docker group. gpasswd -a ${USER} docker - gpasswd -a ${SSH_USER} docker - - # Restart the Docker daemon - #service docker restart + gpasswd -a ${SSH_USERNAME} docker } give_docker_non_root_access diff --git a/test/docker_spec.rb b/test/docker_spec.rb new file mode 100644 index 00000000..93ba3b57 --- /dev/null +++ b/test/docker_spec.rb @@ -0,0 +1,10 @@ +require_relative 'spec_helper' + +describe 'docker' do + docker_string = command('ls /usr/bin/docker').stdout + if docker_string.include? '/usr/bin/docker' then + it 'should have docker installed' do + expect(command('docker run hello-world').exit_status).to eq(0) + end + end +end