You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

172 lines
5.3 KiB

= Docker Install !
Apostolos rootApostolos@swarmlab.io
// Metadata:
:description: Intro and Install
:keywords: iot, swarm. docker
:data-uri:
:toc: right
:toc-title: Table of contents
:toclevels: 4
:source-highlighter: highlight
:icons: font
:sectnums:
{empty} +
== Install Docker Engine
Docker Engine is available on a variety of *Linux platforms*, *macOS* and *Windows 10* through Docker Desktop, and as a static binary installation. Find your preferred operating system below.
=== Supported platforms
* https://docs.docker.com/engine/install/centos/[Install Docker Engine on CentOS^]
* https://docs.docker.com/engine/install/debian/[Install Docker Engine on Debian^]
* https://docs.docker.com/engine/install/fedora/[Install Docker Engine on Fedora^]
* https://docs.docker.com/engine/install/debian/[Install Docker Engine on Debian^]
* https://docs.docker.com/engine/install/ubuntu/[Install Docker Engine on Ubuntu^]
* https://docs.docker.com/docker-for-mac/install/[Install Docker Desktop on Mac^]
* https://docs.docker.com/docker-for-windows/install/[Install Docker Desktop on Windows^]
== Install script
=== A Docker install scripta (generic)
This script is meant for quick & easy install
https://github.com/docker/docker-install[Docker-install^]
=== A Docker install script for Ubuntu
.docker build
[source,sh]
----
#!/bin/bash
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install -y docker-ce
sudo docker run hello-world
# Linux post-install
sudo groupadd docker
sudo usermod -aG docker $USER
sudo systemctl enable docker
----
=== A Docker and Docker Compose install script for Ubuntu
.docker-compose script 1
[source,sh]
----
#!/bin/sh
set -o errexit
set -o nounset
IFS=$(printf '\n\t')
# Docker
sudo apt remove --yes docker docker-engine docker.io containerd runc
sudo apt update
sudo apt --yes --no-install-recommends install apt-transport-https ca-certificates
wget --quiet --output-document=- https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/ubuntu $(lsb_release --codename --short) stable"
sudo apt update
sudo apt --yes --no-install-recommends install docker-ce docker-ce-cli containerd.io
sudo usermod --append --groups docker "$USER"
sudo systemctl enable docker
printf '\nDocker installed successfully\n\n'
printf 'Waiting for Docker to start...\n\n'
sleep 5
# Docker Compose
sudo wget --output-document=/usr/local/bin/docker-compose "https://github.com/docker/compose/releases/download/$(wget --quiet --output-document=- https://api.github.com/repos/docker/compose/releases/latest | grep --perl-regexp --only-matching '"tag_name": "\K.*?(?=")')/run.sh"
sudo chmod +x /usr/local/bin/docker-compose
sudo wget --output-document=/etc/bash_completion.d/docker-compose "https://raw.githubusercontent.com/docker/compose/$(docker-compose version --short)/contrib/completion/bash/docker-compose"
printf '\nDocker Compose installed successfully\n\n'
----
.docker-compose script 2
[source,sh]
----
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
----
[[cheat-error]]
== Get certificates
=== Get https ://registry.vlabs.uniwa.gr:5080/v2/: x509: certificate
```
Pulling ...
ERROR: Get https://registry.vlabs.uniwa.gr:5080/v2/: x509: certificate signed by unknown authority
```
- run
```
$ sudo su
# touch set-ca.sh
```
- copy-paste lines
```
registry_address=registry.vlabs.uniwa.gr
registry_port=5043
mkdir -p /etc/docker/certs.d/$registry_address:$registry_port
openssl s_client -showcerts -connect $registry_address:$registry_port < /dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /etc/docker/certs.d/$registry_address:$registry_port/ca.crt
registry_port=5080
mkdir -p /etc/docker/certs.d/$registry_address:$registry_port
openssl s_client -showcerts -connect $registry_address:$registry_port < /dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /etc/docker/certs.d/$registry_address:$registry_port/ca.crt
registry_address=hub.swarmlab.io
registry_port=5443
mkdir -p /etc/docker/certs.d/$registry_address:$registry_port
openssl s_client -showcerts -connect $registry_address:$registry_port < /dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /etc/docker/certs.d/$registry_address:$registry_port/ca.crt
registry_port=5480
mkdir -p /etc/docker/certs.d/$registry_address:$registry_port
openssl s_client -showcerts -connect $registry_address:$registry_port < /dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /etc/docker/certs.d/$registry_address:$registry_port/ca.crt
```
=== exec file
```
sudo bash ./set-ca.sh
```
=== Error response from daemon
```
docker: Error response from daemon: Get https://registry.vlabs.uniwa.gr:5080/v2/: dial tcp: lookup registry.vlabs.uniwa.gr on [::1]:53: read udp [::1]:56425->[::1]:53: read: connection refused.
```
Try again!