Docker

From campisano.org
Jump to navigation Jump to search

Install

Docker CE

From deb packages

cd /tmp
curl -OL https://download.docker.com/linux/debian/dists/stretch/pool/stable/amd64/docker-ce_19.03.0~3-0~debian-stretch_amd64.deb
curl -OL https://download.docker.com/linux/debian/dists/stretch/pool/stable/amd64/containerd.io_1.2.6-3_amd64.deb
curl -OL https://download.docker.com/linux/debian/dists/stretch/pool/stable/amd64/docker-ce-cli_19.03.0~3-0~debian-stretch_amd64.deb
dpkg -i containerd.io_1.2.6-3_amd64.deb docker-ce-cli_19.03.0~3-0~debian-stretch_amd64.deb docker-ce_19.03.0~3-0~debian-stretch_amd64.deb
rm -f *.deb

From docker repository

su -
apt-get install      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"
etckeeper commit
apt-get update
apt-get install docker-ce
# test
docker run hello-world
exit

Docker Compose (optional)

From debian repository

apt-get install docker-compose

From pip

pip install docker-compose --user

From docker documentation

su -
curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
chmod 0755 /usr/local/bin/docker-compose
docker-compose --version
exit

User permissions

su -
# docker-ce already create docker group
# so we need to add normal users to this group if them can run docker images
usermod -aG docker <USERNAME>
exit

Test and Run

# update current user permission reloading bash shell, for not shells you will need to log off and login again
exec su $USER
# test
docker run hello-world
# download and run a basic image
docker run -it --name deb-stretch debian:stretch /bin/bash