<\/span><\/h2>\r\n\r\n\r\n\r\nConnect to your server via SSH as the root user using the following command:<\/p>\r\n\r\n\r\n\r\n
ssh root@IP_ADDRESS -p PORT_NUMBER<\/pre>\r\n\r\n\r\n\r\nRemember to replace \u201cIP_ADDRESS<\/span>\u201d and \u201cPORT_NUMBER<\/span>\u201d with your actual server IP address and SSH port number. Replace \u201croot\u201d with your admin username if you\u2019re not planning on using the root account.<\/p>\r\n\r\n\r\n\r\nBefore starting with the installation, we need to update the OS packages to their latest versions.<\/p>\r\n\r\n\r\n\r\n
We can do this by running the following commands:<\/p>\r\n\r\n\r\n\r\n
$ apt-get update \r\n$ apt-get upgrade<\/pre>\r\n\r\n\r\n\r\nOnce the upgrade is complete, we can move on to the next step.<\/p>\r\n\r\n\r\n\r\n
<\/span>Step 2: Install Dependency packages<\/span><\/h2>\r\n\r\n\r\n\r\nStart the installation by ensuring that all the packages used by docker as dependencies are installed.<\/p>\r\n\r\n\r\n\r\n
apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common build-essential<\/pre>\r\n\r\n\r\n\r\n<\/span>Step 3: Setting Up Docker Repository<\/span><\/span><\/h2>\r\n\r\n\r\n\r\nTo add the Docker repository to our server, we need to add the GPG keys first with the following commands:<\/p>\r\n\r\n\r\n\r\n
curl -fsSL https:\/\/download.docker.com\/linux\/debian\/gpg | sudo apt-key add -<\/pre>\r\n\r\n\r\n\r\nOnce added, add the repository pointing to \u2018stable\u2019 update channel.<\/p>\r\n\r\n\r\n\r\n
add-apt-repository \"deb [arch=amd64] https:\/\/download.docker.com\/linux\/debian $(lsb_release -cs) stable\"<\/pre>\r\n\r\n\r\n\r\nWe can now update our packages, which should include the repository from Docker.<\/p>\r\n\r\n\r\n\r\n
apt-get update<\/pre>\r\n\r\n\r\n\r\nAfter applying command, you should see the repository link added:<\/p>\r\n\r\n\r\n\r\n
Get:5 https:\/\/download.docker.com\/linux\/debian stretch InRelease [44.8 kB]\r\nGet:7 https:\/\/download.docker.com\/linux\/debian stretch\/stable amd64 Packages [8,437 B]<\/pre>\r\n\r\n\r\n\r\n<\/span>Step 4: Installing Docker CE<\/span><\/span><\/h2>\r\n\r\n\r\n\r\nAfter setting up the repository, we can now install the Docker CE, as well as the Docker CLI by running the following command:<\/p>\r\n\r\n\r\n\r\n
apt-get install -y docker-ce docker-ce-cli<\/pre>\r\n\r\n\r\n\r\nThis might take some time as it will also install any additional libraries that it requires.<\/p>\r\n\r\n\r\n\r\n
Once the installation is done, verify that the docker service is running by typing:<\/p>\r\n\r\n\r\n\r\n
systemctl status docker<\/pre>\r\n\r\n\r\n\r\nOutput:<\/p>\r\n\r\n\r\n\r\n
docker.service - Docker Application Container Engine\r\n Loaded: loaded (\/lib\/systemd\/system\/docker.service; enabled; vendor preset: enabled)\r\n Active: active (running) since Sun 2019-07-14 03:40:16 EDT; 38s ago\r\n Docs: https:\/\/docs.docker.com\r\n Main PID: 4434 (dockerd)\r\n CGroup: \/system.slice\/docker.service\r\n \u2514\u25004434 \/usr\/bin\/dockerd -H fd:\/\/ --containerd=\/run\/containerd\/containerd.sock<\/pre>\r\n\r\n\r\n\r\nYou can also check and verify the Docker version using:<\/p>\r\n\r\n\r\n\r\n
docker -v<\/pre>\r\n\r\n\r\n\r\nOutput:<\/p>\r\n\r\n\r\n\r\n
Docker version 18.09.7, build 2d0083d<\/pre>\r\n\r\n\r\n\r\nFinally, make sure that the docker service will run at boot:<\/p>\r\n\r\n\r\n\r\n
systemctl enable docker<\/pre>\r\n\r\n\r\n\r\nThe\u00a0docker<\/code> the group\u00a0is created but no users are added. Add\u00a0your\u00a0normal user to the group to run docker commands as a non-privileged\u00a0user.<\/p>\r\n\r\n\r\n\r\nsudo usermod -aG docker $USER<\/pre>\r\n\r\n\r\n\r\n