Install Docker and Compose on Ubuntu 16.04 LTS


apt-get update

apt-get install \
 apt-transport-https \
 ca-certificates \
 curl \

curl -fsSL | sudo apt-key add -

add-apt-repository \
 "deb [arch=amd64] \
 $(lsb_release -cs) \

apt-get update

apt-get install -y \
  docker-ce \

If you plan on using the –memory flag when creating containers, you may need to enable memory and swap accounting in the Kernel.

  1. Log into the Ubuntu host as a user with sudo privileges.
  2. 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"
  3. Save and close the file.
  4. 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 Docker Post-Installation Steps for Linux.