Docker Install | Kill Docker Auto Updates

UPDATE : 2023-07-03 : Docker Desktop 4.19.0 (106363)

wsl --update

Docker for Windows a.k.a. Docker Desktop

Current setup …

choco install docker-desktop --version 3.2.2

History …

:: Tested : ok : Updater disabled
choco install docker-desktop --version 3.1.0
:: Tested : ok : Updater disabled
choco install docker-desktop --version 3.2.2
:: Tested : FAILs @ recompile to disable Updater
choco install docker-desktop --version 3.3.3
:: Tested : FAILs @ WSL
choco install docker-desktop --version 3.5.0

2021-07-01

FIX : Expose tcp://0.0.0.0:2376 (for WSL etal)

Does nothing.

Add these key-val pair(s) to ~/.docker/daemon.json

Insecure

"hosts": ["unix:///var/run/docker.sock", "tcp://0.0.0.0:2376"],

+Secure

"hosts": ["unix:///var/run/docker.sock", "tcp://0.0.0.0:2376"],
"tlscacert": "~/.docker/certs/ca.pem",
"tlscert": "~/.docker/certs/server-cert.pem",
"tlskey": "~/.docker/certs/server-key.pem",
"tlsverify": true
mkdir ~/.docker/certs
cd ~/.docker/certs
openssl genrsa -aes256 -out ca-key.pem 4096  # enter passphrase
openssl req -new -x509 -days 365 -key ca-key.pem -sha256 -out ca.pem  # enter localhost or FQDN
openssl genrsa -out server-key.pem 4096
openssl req -subj "/CN=localhost" -sha256 -new -key server-key.pem -out server.csr
openssl x509 -req -days 365 -sha256 -in server.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out server-cert.pem
echo subjectAltName = DNS:localhost,IP:127.0.0.1 >> extfile.cnf
echo extendedKeyUsage = serverAuth >> extfile.cnf
openssl x509 -req -days 365 -sha256 -in server.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out server-cert.pem -extfile extfile.cnf
openssl genrsa -out key.pem 4096
openssl req -subj '/CN=client' -new -key key.pem -out client.csr
echo extendedKeyUsage = clientAuth > extfile-client.cnf
openssl x509 -req -days 365 -sha256 -in client.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out cert.pem -extfile extfile-client.cnf

2020-09-14

@ Windows 10 (Pro/Ent)

  1. Enable Hyper-V (Win10 OS Feature), and reboot
  2. Download and install

  3. Installs as a VM (MobyLinuxVM DockerDesktopVM) under Hyper-V, which is a Type-1 (hardware virtualization) hypervisor. Requires an Intel CPU with VT-x.

    • Docker VM: 2
    • CPU, 2GB
    • RAM, DockerNAT
    • Virtual Switch, 60GB
    • @ MobyLinuxVM.vhdx (docker-for-win.iso) @ %ProgramFiles%\Docker\Docker\Resources.
  4. PowerShell native, but can get other shells to work.

@ Win7/8/8.1/10-Home

@ Linux

The main Docker CLI tool, docker, is the "Docker Engine" (tool). Depending on Linux distro/version, the package manager/repo may identify it only by docker, docker-ce, docker-engine, or something else. (See sudo yum update -y # Update pkg-mgr index sudo yum install -y docker # Install latest Docker CE

Method 2

# Setup repo
sudo yum install -y yum-utils
sudo yum-config-manager \
    --add-repo \
    'https://download.docker.com/linux/centos/docker-ce.repo'
sudo yum makecache fast
# Install
sudo yum install -y docker-ce # latest version

@ Debian/Ubuntu 18

# per Docker repo
export DOCKER_CHANNEL='edge'
export DOCKER_COMPOSE_VERSION='1.21.0'
sudo apt-get update -y  # Update pkg-mgr index
# Install packages that allow apt to use a repo over HTTPS.
sudo apt-get install -y \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common
# Add Docker's official GPG key.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# Verify the fingerprint.
sudo apt-key fingerprint 0EBFCD88
# Pick the release channel.
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   ${DOCKER_CHANNEL}"
# Update the apt package index.
sudo apt-get update
# Install the latest version of Docker CE.
sudo apt-get install -y docker-ce

Config

systemctl start docker   # systemd
service docker start     # equiv. non-systemd (AWS AMI)

# Allow user access Docker CLI, sans root.
sudo usermod -aG docker $USER  # 'ec2-user' @ AWS EC2, 'vagrant' @ Vagrant box, ... 
# Update to take effect now
sudo newgrp docker

Docker bash completion
(Had no effect whatsoever @ WSL Ubuntu.)

sudo curl https://raw.githubusercontent.com/docker/docker-ce/master/components/cli/contrib/completion/bash/docker -o /etc/bash_completion.d/docker.sh

Test Install

# Test (sans sudo) 
docker info                # prints Docker env. info 
# Docker's "Hello World" container 
docker run hello-world     # prints to STDOUT
# Busybox
docker run -it busybox sh  # interactive terminal  
# Alpine Linux
docker run -it alpine      # default (auto) CMD is `sh` (ash shell)
# Nginx server @ bkgnd process ...
docker run -d -p 80:80 --name 'proxy' nginx  
# ... then browse or curl http://localhost:80 

Install other Docker CLI tools

Docker Compose (releases)

# Install Docker Compose
export _v='1.23.2'  # https://github.com/docker/compose/releases
base=https://github.com/docker/compose/releases/download/${_v} \
    && sudo curl -L $base/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose \
    && sudo chmod +x /usr/local/bin/docker-compose

Docker Machine (releases)

# Install Docker Machine
export _v='v0.16.0'  # https://github.com/docker/machine/releases
base=https://github.com/docker/machine/releases/download/${_v} \
    && curl -L $base/docker-machine-$(uname -s)-$(uname -m) -o /tmp/docker-machine \
    && sudo install /tmp/docker-machine /usr/local/bin/docker-machine

# Config CURRENT SHELL per SWARM_MGR so can use docker CLI tool
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.1.11:2376"  
# port 2376 supposedly problematic, but lack certs for 2377
export DOCKER_CERT_PATH="/c/Users/X1/.docker/machine/machines/$_SWARM_MGR"
export DOCKER_MACHINE_NAME="$_SWARM_MGR"
export COMPOSE_CONVERT_WINDOWS_PATHS="true"

Docker @ WSL

Install/setup such that Docker client @ WSL communicates with Docker-for-Windows server, instead of its own. This is analogous to the Kubernetes method for integrating the Docker-for-Windows client with Minikube's docker-server. See Minikube.Install.md (MD | HTML).

  1. Select @ Docker-for-Windows (GUI)
    • > Settings > "Expose daemon on tcp://loc..." (check-box)
  2. Install Docker (docker-engine), @ WSL console, per distro (methods above)
  3. @ ~/.bashrc

    export DOCKER_HOST=tcp://0.0.0.0:2375
    
  4. Ensure Volume Mounts Work

    • @ /etc/wsl.conf

      [automount]
      root = /
      options = "metadata"
      
      # fix /mnt/c (if need be)
      sudo mkdir /c
      sudo mount --bind /mnt/c /c
      
    • Test @ WSL, while Docker-for-Windows is running ...

      docker info  # should print its settings
      

Docker.md (Docker.sh (link)