Install Docker and Compose on Debian 9 Stretch

#!/bin/bash

apt-get update

apt-get install -y \
  apt-transport-https \
  ca-certificates \
  curl \
  gnupg2 \
  software-properties-common

curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -

add-apt-repository \
  "deb [arch=amd64] https://download.docker.com/linux/debian \
  $(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.

  1. Log into the Debian 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.

Leave a Reply

Your email address will not be published. Required fields are marked *