本篇介绍了在Mac OS, Windows, Linux下的Docker安装方法。
先来一个官方的介绍:
Docker Engine is available for Linux (CentOS, Debian, Fedora, Oracle Linux, RHEL, SUSE, and Ubuntu) or Windows Server operating systems and is based on containerd – the open source container runtime project that Docker donated to the Cloud Native Computing Foundation (CNCF) in 2017. It is available as both a free community-supported engine and as a commercially-supported enterprise engine (Docker Engine-Enterprise) that also forms the foundation for an enterprise container platform.
基本上全平台已经覆盖,英文好的同学,可以自取。
Mac OS上的Docker安装方法方法一官方dmg:
官方下载地址:
Docker Descktop for Mac
对系统的要求:
Requires Apple Mac OS Sierra 10.12 or above. Download Docker Toolbox for previous OS versions.
只要系统是 Mac OS Sierra 10.12以上即可。
下载完Docker.dmg安装包之后,双击即可以安装,可能需要系统管理员权限,输入密码即可。
运行过后,小图标:
图片裂了,联系:lw96@live.comMac上Docker安装运行之后
安装完之后,在终端工具中,使用docker version来查看Docker版本。
图片裂了,联系:lw96@live.comdocker版本
设置中国区加速地址:
图片裂了,联系:lw96@live.comdocker加速
阿里云加速:Docker 镜像加速器
方法二brew cask:
brew update
brew cask install docker
删除的方法, 还需要手动删除Docker.app
brew cask uninstall docker上面的命令将会把Docker安装在Applications目录下。
Windows上Docker安装官方下载地址:Docker Desktop for Windows
对系统的要求:
Requires Microsoft Windows 10 Professional or Enterprise 64-bit. For previous versions get Docker Toolbox.
需要Windows 10专业版及企业的64位版本,在Windows server 2016以上亲测是可用的。Windows 8/7/Vista/Xp之类的,就别想了,老实去装Windows 10或者虚拟机中去使用。
图片裂了,联系:lw96@live.comwindows-docker安装示例
Linux上Docker安装Centos中Docker安装方法先删除旧的版本(如果没有可以跳过)
$ sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine安装必须的依赖:
$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2添加stable的Docker-ce的源:
$ sudo yum-config-manager –add-repo https://download.docker.com/linux/centos/docker-ce.repo安装docker-ce:
$ sudo yum install docker-ce docker-ce-cli containerd.io选择指定的安装版本(可选)
$ yum list docker-ce –showduplicates | sort -r
docker-ce.x86_64 3:18.09.1-3.el7 docker-ce-stabledocker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stabledocker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stabledocker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable我们来举个例子,比如我们要安装3:18.09.1-3.el7这个版本,使用如下命令结构:
$ sudo yum install docker-ce- docker-ce-cli- containerd.io命令说明:
第一部分是docker-ce,第二部分是版本号18.09.1,看明白了吗?就是这样子:
$ sudo yum install -y docker-ce-18.09.1 docker-ce-cli-18.09.1启动服务并测试一下:
启动服务
sudo systemctl start docker
来一个Hello World吧
sudo docker run hello-worldUnable to find image ‘hello-world:latest’ locallylatest: Pulling from library/hello-world1b930d010525: Pull completeDigest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535Status: Downloaded newer image for hello-world:latest
Hello from Docker!This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
- The Docker client contacted the Docker daemon.
- The Docker daemon pulled the “hello-world” image from the Docker Hub.
(amd64) - The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading. - The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:https://hub.docker.com/
For more examples and ideas, visit:https://docs.docker.com/get-started/如果看到上面的提示,说明Docker已经成功安装并运行了了。
关于升级&删除:
升级:
更新所有
yum -y update
更新指定
yum -y update docker-ce docker-ce-cli containerd.io删除:
sudo yum remove docker-ce
删除文件系统
sudo rm -rf /var/lib/dockerDebian中Docker的安装方法删除旧的版本(可跳过)
$ sudo apt-get remove docker docker-engine docker.io containerd runc安装依赖:
$ sudo apt-get update
$ sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
添加GPG key
$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add –
$ sudo apt-key fingerprint 0EBFCD88
pub 4096R/0EBFCD88 2017-02-22Key fingerprint = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88uid Docker Release (CE deb)sub 4096R/F273FCD8 2017-02-22使用stable安装源:
x86_64 / amd64armhfarm64$ sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable”安装docker-ce:
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io安装指定的版本:(可选)
$ apt-cache madison docker-ce
docker-ce | 5:18.09.1~3-0~debian-stretch | https://download.docker.com/linux/debian stretch/stable amd64 Packagesdocker-ce | 5:18.09.0~3-0~debian-stretch | https://download.docker.com/linux/debian stretch/stable amd64 Packagesdocker-ce | 18.06.1~ce~3-0~debian | https://download.docker.com/linux/debian stretch/stable amd64 Packagesdocker-ce | 18.06.0~ce~3-0~debian | https://download.docker.com/linux/debian stretch/stable amd64 Packages…安装格式:
$ sudo apt-get install docker-ce= docker-ce-cli= containerd.io举例说明:比如要安装5:18.09.1~3-0~debian-stretch版本的docker的话:
$ sudo apt-get install docker-ce=18.09.1 docker-ce-cli=18.09.1 containerd.io启动服务并测试:
$ sudo service docker start
查看Docker运行状态
$ sudo service docker status
$ sudo docker run hello-worldUbuntu中Docker安装方法删除旧的版本(可跳过)
$ sudo apt-get remove docker docker-engine docker.io containerd runc安装依赖:
$ sudo apt-get update
$ sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
添加GPG key
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
$ sudo apt-key fingerprint 0EBFCD88
pub rsa4096 2017-02-22 [SCEA]9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88uid [ unknown] Docker Release (CE deb)sub rsa4096 2017-02-22 [S]使用stable安装源:
x86_64/amd64armhfarm64ppc64le (IBM Power)s390x (IBM Z)$ sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable”安装docker-ce:
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io安装指定的版本:(可选)
$ apt-cache madison docker-ce
docker-ce | 5:18.09.1~3-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packagesdocker-ce | 5:18.09.0~3-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packagesdocker-ce | 18.06.1~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packagesdocker-ce | 18.06.0~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages…安装格式:
$ sudo apt-get install docker-ce= docker-ce-cli= containerd.io举例说明:比如要安装5:18.09.1~3-0~ubuntu-xenial版本的docker的话:
$ sudo apt-get install docker-ce=18.09.1 docker-ce-cli=18.09.1 containerd.io启动服务并测试:
$ sudo service docker start
查看Docker运行状态
$ sudo service docker status
$ sudo docker run hello-worldDocker-compose集合命令Compose工具是一个批量工具,用于运行与管理多个docker容器。
官方文档:Install Docker Compose
在Mac/Windows中,已经集成了docker-compose命令
在WindowsServer中 先启动PowerShell
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12然后运行如下命令:
Invoke-WebRequest “https://github.com/docker/compose/releases/download/1.23.2/docker-compose-Windows-x86_64.exe” -UseBasicParsing -OutFile $Env:ProgramFilesDockerdocker-compose.exe然后测试一下:docker-compose –version
Linux中:
下载docker-compose
sudo curl -L “https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)” -o /usr/local/bin/docker-compose
给予执行权限
sudo chmod +x /usr/local/bin/docker-compose
测试命令
$ docker-compose –versiondocker-compose version 1.23.2, build 1110ad01已禁用此文档中的部分内容
今天的文章Docker入门之安装教程分享到此就结束了,感谢您的阅读。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:http://bianchenghao.cn/20904.html