Linux/Docker/Installation: Difference between revisions

From Wiki
< Linux‎ | Docker
mNo edit summary
 
(21 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Installation on Ubuntu ==
== Installation on Ubuntu ==
* Docker from default repo
<pre>
<pre>
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt update
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt install docker.io
</pre>
 
* Docker from Docker apt repo (Ubuntu)
<pre>
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
 
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
 
sudo apt update
sudo apt update
apt-cache policy docker-ce
apt-cache policy docker-ce
sudo apt install docker-ce
sudo apt install docker-ce
sudo systemctl status docker
deprecated?:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/docker.gpg
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
deprecated:
(curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -) deprecated
(curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor | sudo tee /etc/apt/keyrings/docker.gpg) deprecated
(curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/docker.gpg) working ?
</pre>
* Docker from Docker apt repo (Debian)
<pre>
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update


sudo systemctl status docker
sudo apt-get install docker-ce
</pre>
</pre>


* Docker in WSL2 autostart (without systemd)
<pre>
if grep -q "microsoft" /proc/version > /dev/null 2>&1; then
    if service docker status 2>&1 | grep -q "is not running"; then
        wsl.exe --distribution "${WSL_DISTRO_NAME}" --user root \
            --exec /usr/sbin/service docker start > /dev/null 2>&1
    fi
fi
</pre>


* Set different docker root dir:
* Set different docker root dir:
Line 19: Line 71:
ExecStart=/usr/bin/dockerd -g /srv/docker-lib -H fd://
ExecStart=/usr/bin/dockerd -g /srv/docker-lib -H fd://
</pre>
</pre>


== Installation on Windows, control from WSL ==
== Installation on Windows, control from WSL ==
Line 32: Line 83:
<pre>
<pre>
# latest version number
# latest version number
#git ls-remote https://github.com/docker/compose | grep refs/tags | grep -oP "[0-9]+\.[0-9][0-9]+\.[0-9]+$" | tail -n 1
curl --silent "https://api.github.com/repos/docker/compose/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'
curl --silent "https://api.github.com/repos/docker/compose/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'


sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/v2.20.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /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
docker-compose --version
docker-compose --version
</pre>
</pre>
Line 42: Line 93:
== ctop - commandline monitoring ==
== ctop - commandline monitoring ==
<pre>
<pre>
sudo wget https://github.com/bcicen/ctop/releases/download/v0.7.3/ctop-0.7.3-linux-amd64 -O /usr/local/bin/ctop
sudo wget https://github.com/bcicen/ctop/releases/download/v0.7.7/ctop-0.7.7-linux-amd64 -O /usr/bin/ctop
sudo chmod +x /usr/local/bin/ctop
sudo chmod +x /usr/bin/ctop
</pre>
</pre>


[[Category:Linux/Docker]]
[[Category:Linux/Docker]]
[[Category:Linux]]
[[Category:Linux]]

Latest revision as of 17:15, 2 November 2024

Installation on Ubuntu

  • Docker from default repo
sudo apt update
sudo apt install docker.io
  • Docker from Docker apt repo (Ubuntu)
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

sudo apt update
apt-cache policy docker-ce
sudo apt install docker-ce
sudo systemctl status docker

deprecated?:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/docker.gpg
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

deprecated:
(curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -) deprecated
(curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor | sudo tee /etc/apt/keyrings/docker.gpg) deprecated
(curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/docker.gpg) working ?
  • Docker from Docker apt repo (Debian)
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

sudo apt-get install docker-ce 


  • Docker in WSL2 autostart (without systemd)
if grep -q "microsoft" /proc/version > /dev/null 2>&1; then
    if service docker status 2>&1 | grep -q "is not running"; then
        wsl.exe --distribution "${WSL_DISTRO_NAME}" --user root \
            --exec /usr/sbin/service docker start > /dev/null 2>&1
    fi
fi
  • Set different docker root dir:
vi /etc/systemd/system/docker.service.d/docker.root.conf

[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -g /srv/docker-lib -H fd://

Installation on Windows, control from WSL

  • Install Docker for Windows
  • Settings: Expose daemon without TLS
  • WSL:
    • Follow "Installation on Ubuntu" instructions from above
    • echo "export DOCKER_HOST=localhost:2375" >> ~/.bashrc


Docker compose installation on Ubuntu

# latest version number
curl --silent "https://api.github.com/repos/docker/compose/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'

sudo curl -L "https://github.com/docker/compose/releases/download/v2.20.2/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
docker-compose --version

ctop - commandline monitoring

sudo wget https://github.com/bcicen/ctop/releases/download/v0.7.7/ctop-0.7.7-linux-amd64 -O /usr/bin/ctop
sudo chmod +x /usr/bin/ctop