Popular blog tags

docker(1)-install docker on windows,debian,etc

Published

安装docker时,官网有docker desktop和docker engine两种

首先,必须在docker desktop 和 Docker Engine之间做出选择。

其次,要检查自己的操作系统的环境,Docker对操作系统的版本是有要求的。

 

Install Docker Engine 

Docker Engine installation overview.

https://docs.docker.com/engine/install/

 

https://www.docker.com/products/docker-desktop

Install Docker Engine on Debian

Docker — 从入门到实践

https://yeasy.gitbook.io/docker_practice/install/raspberry-pi

Remove old docker on debian

sudo apt-get remove docker \
               docker-engine \
               docker.io

or

sudo apt-get remove docker \
               docker \
               docker.io

Install

$ sudo apt-get update

$ sudo apt-get install \
     apt-transport-https \
     ca-certificates \
     curl \
     gnupg \
     lsb-release

 

Debian 11 安装 Docker Engine

https://www.cnblogs.com/TopStop/p/16275303.html

Install Docker Engine on ubuntu

https://docs.docker.com/engine/install/ubuntu/

 

ubuntu 18.04 *64  vultr

root@vultr:~# docker version
Client: Docker Engine - Community
 Version:           24.0.2
 API version:       1.43
 Go version:        go1.20.4
 Git commit:        cb74dfc
 Built:             Thu May 25 21:52:13 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          24.0.2
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.4
  Git commit:       659604f
  Built:            Thu May 25 21:52:13 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.21
  GitCommit:        3dce8eb055cbb6872793272b4f20ed16117344f8
 runc:
  Version:          1.1.7
  GitCommit:        v1.1.7-0-g860f061
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

 

run ok

Install Docker Engine on Raspberry Pi

https://yeasy.gitbook.io/docker_practice/install/raspberry-pi

https://docs.docker.com/engine/install/raspbian/#prerequisites

 

卸载 docker

删除安装包:

apt-get purge docker-ce -y
apt-get purge docker-ce-cli -y
apt-get purge containerd.io -y

查看是否卸载完毕

apt list --installed | grep docker
apt list --installed | grep containerd.io

 

删除镜像、容器、配置文件等内容:

rm -rf /var/lib/docker
rm -rf /var/run/docker
rm -rf /etc/docker
rm -rf /run/docker.sock
rm -rf /var/lib/containerd
rm -rf /run/containerd
rm -rf /opt/containerd

Installing Docker Desktop on windows

https://github.com/docker/labs/blob/master/windows/windows-containers/README.md

 

Installing Docker   on windows

You can run Windows containers on Windows 10, Windows Server 2016 and Windows Server 2019.

The latest release of Windows to support Docker containers is Windows Server 2019, and Windows 10 with the 1809 update. There are many enhancements from the original Windows containers release in Server 2016.

Install Docker Desktop on Windows 10
Install Docker Enterprise Engine on Windows Server

https://github.com/docker/labs/blob/master/windows/windows-containers/README.md

Install Docker Desktop on Windows 10

 

System requirements

WSL 2 backend

WSL version 1.1.3.0 or above.
Windows 11 64-bit: Home or Pro version 21H2 or higher, or Enterprise or Education version 21H2 or higher.
Windows 10 64-bit: Home or Pro 21H2 (build 19044) or higher, or Enterprise or Education 21H2 (build 19044) or higher.

 

https://docs.docker.com/desktop/install/windows-install/

 

 

docker engine vs docker desktop vs docker-compose

docker desktop


docker desktop包含虚拟机、图形界面及其他特性比如带了一个单节点的kubernetes集群,虚拟机里有一个Docker CE (Docker Community Edition)守护进程。

docker desktop组成部分

https://docs.docker.com/desktop/

Docker Engine
Docker CLI client
Docker Buildx
Extensions
Docker Compose
Docker Content Trust
Kubernetes
Credential Helper

docker engine


docker engine,根据官方文档包含三部分,

守护进程dockerd
api,程序可通过api与dockerd交互
命令行工具客户端docker,命令docker command中的docker

 

root@vultr:~# sudo docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

 

What is the difference between Docker Desktop for Linux and Docker Engine

https://docs.docker.com/desktop/faqs/linuxfaqs/#what-is-the-difference-between-docker-desktop-for-linux-and-docker-engine

Docker Engine comes bundled with Docker Desktop for Linux. This is the easiest and quickest way to get started.

Docker Desktop for Linux runs a Virtual Machine (VM).

Sometimes we want to make use of new operating system features. Because we control the kernel and the OS inside the VM, we can roll these out to all users immediately, even to users who are intentionally sticking on an LTS version of their machine OS.

在docker desktop里,docker客户端是在宿主机中,守护进程在虚拟机里。当要访问docker desktop的ip时,要谨记一条-docker network存在于虚拟机中,即使使用docker run --net host那也是使用虚拟机的host network,而不是物理机的network。docker container运行在虚拟机中,其他一切都是结果。
在Windows和MacOS中,要想运行linux容器,必须有虚拟机,在linux中是不需要的;不过,为了一致体验,如果在linux中安装desktop也会安装一个虚拟机。

小结
如果装在macOS、windows、linux等有图形的桌面电脑,则用docker desktop。比如windows电脑、macos电脑、ubuntu、fedora电脑。
如果装在没有图形的电脑,则用docker engine,比如公司的centos服务器、阿里云的centos服务器等


 

docker
docker 一般从概念上理解就是指容器化技术,可以用来创建和使用 Linux 的容器。借助 docker,可将容器当做轻巧、模块化的虚拟机使用。同时具备一定的灵活性,从而非常高效的实现对容器的创建、部署、复制和迁移。

docker-compose

传统模式下运维人员需要运行 docker run 来启动各种容器,一旦容器过多,就无法一次性记住所有的运行参数和命令。

这时候我们可以使用 Docker Compose 来解决这个问题。


docker-compose 本身是一个基于 docker 的开源项目,一般用来管理容器服务,通过调用 docker 服务的 API 实现对 docker 容器集群的快速编排。具体的实现方式是通过一个 yaml 配置文件,在其中定义一组相关的容器服务。

https://juejin.cn/post/7034150981071798309

当我们在服务器上部署一个网站时,通常需要部署web服务器、数据库等等
如果我们选择使用 Docker 进行部署,通常会选择一个应用部署一个容器
但每个应用都单独部署容器,并且让容器之间互相联通,是件耗时长且麻烦的事情

而这时候 Docker Compose 就派上用场了
我们通过一个文件,就能让它快速地部署多个容器

 

 


用Docker-Compose管理多容器


在实际场景中我们使用多个容器,比如在某项工作中需要使用5个容器,3个使用已有镜像,2个使用Dockerfile构建的镜像,逐个启动很麻烦。那么有没有简单的方法呢?我们可以使用Docker集群管理三剑客之一的Docker- Compose(有时也简称之为Compose)来编排容器。Compose是用Python语言开发的Docker集群管理的工具和轻量级编排工具,我们通过编写YAML文件可以对一组容器进行编排,其语法简洁明了、操作简单,堪称Docker容器编排的神器。

 

Debian 12 / Ubuntu 22.04 安装 Docker 以及 Docker Compose 教程

https://u.sb/debian-install-docker/