#!/bin/bash
apt-get update
apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt-get update
apt-get install -y \
docker-ce \
docker-compose
If you plan on using the –memory flag when creating containers, you may need to enable memory and swap accounting in the Kernel.
- Log into the Ubuntu host as a user with sudo privileges.
- Edit the /etc/default/grub file. Add or edit the GRUB_CMDLINE_LINUX line to add the following two key-value pairs:
GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"
- Save and close the file.
- Update GRUB.
sudo update-grub
If your GRUB configuration file has incorrect syntax, an error occurs. In this case, repeat steps 3 and 4.
The changes take effect when the system is rebooted.
More detailed information can be found in the Linux post-installation steps for Docker Engine