首页 > 其他 > 详细

Docker的使用及基本用法

时间:2020-08-25 14:44:49      阅读:69      评论:0      收藏:0      [点我收藏+]

1:安装

 1.1:在ubuntu1804上安装docker的社区版,具体配置信息如下:

 1 # step 1: 安装必要的一些系统工具
 2 root@template-ubuntu-20200606:~# sudo apt-get update
 3 root@template-ubuntu-20200606:~# sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
 4 # step 2: 安装GPG证书
 5 root@template-ubuntu-20200606:~# curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
 6 # Step 3: 写入软件源信息
 7 root@template-ubuntu-20200606:~# sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
 8 # Step 4: 更新并安装软件源里Docker-CE的最新版
 9 root@template-ubuntu-20200606:~# sudo apt-get -y update
10 root@template-ubuntu-20200606:~# sudo apt-get -y install docker-ce
11 
12 # 安装指定版本的Docker-CE:
13 # Step 1: 查找Docker-CE的版本:
14 root@template-ubuntu-20200606:~# apt-cache madison docker-ce
15 #   docker-ce | 17.03.1~ce-0~ubuntu-xenial | https://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages
16 #   docker-ce | 17.03.0~ce-0~ubuntu-xenial | https://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages
17 # Step 2: 安装指定版本的Docker-CE: (VERSION例如上面的17.03.1~ce-0~ubuntu-xenial)
18 root@template-ubuntu-20200606:~#  sudo apt-get -y install docker-ce=[VERSION]  docker-ce-cli=[VERSION]

  这了目前这步,docker已经安装成功

  启动并设置docker开机启动 

1 启动并设置开机启动
2 root@template-ubuntu-20200606:~# systemctl start docker
3 root@template-ubuntu-20200606:~# systemctl enable docker
4 Synchronizing state of docker.service with SysV service script with /lib/systemd/systemd-sysv-install.
5 Executing: /lib/systemd/systemd-sysv-install enable docker 

  验证docker的版本,见如下图片

1 root@template-ubuntu-20200606:~# docker -v
2 Docker version 18.09.9, build 039a7df9ba 

  技术分享图片

1.2:在centos7系统上通过yum安装docker的社区版

 1 # step 1: 安装必要的一些系统工具
 2 [root@molson ~]#  yum install -y yum-utils device-mapper-persistent-data lvm2
 3 # Step 2: 添加软件源信息
 4 [root@molson ~]#  yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
 5 # Step 3: 更新并安装Docker-CE
 6 [root@molson ~]#  yum makecache fast
 7 [root@molson ~]#  yum -y install docker-ce
 8 # Step 4: 开启Docker服务
 9 [root@molson ~]# service docker start
10 
11 # 注意:
12 # 官方软件源默认启用了最新的软件,您可以通过编辑软件源的方式获取各个版本的软件包。例如官方并没有将测试版本的软件源置为可用,您可以通过以下方式开启。同理可以开启各种测试版本等。
13 # vim /etc/yum.repos.d/docker-ee.repo
14 #   将[docker-ce-test]下方的enabled=0修改为enabled=1
15 #
16 # 安装指定版本的Docker-CE:
17 # Step 1: 查找Docker-CE的版本:
18 [root@molson ~]#  yum list docker-ce.x86_64 --showduplicates | sort -r
19 #   Loading mirror speeds from cached hostfile
20 #   Loaded plugins: branch, fastestmirror, langpacks
21 #   docker-ce.x86_64            17.03.1.ce-1.el7.centos            docker-ce-stable
22 #   docker-ce.x86_64            17.03.1.ce-1.el7.centos            @docker-ce-stable
23 #   docker-ce.x86_64            17.03.0.ce-1.el7.centos            docker-ce-stable
24 #   Available Packages
25 # Step2: 安装指定版本的Docker-CE: (VERSION例如上面的17.03.0.ce.1-1.el7.centos)
26 [root@molson ~]#  yum -y install docker-ce-版本 docker-ce-cli-版本

  到了这步,dockers已经按照成功了,设置docker开机启动

1 [root@molson ~]# systemctl start docker
2 [root@molson ~]# systemctl enable docker
3 Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

  验证按照docker的版本信息

1 [root@molson ~]# docker -v
2 Docker version 18.09.9, build 039a7df9ba

  技术分享图片

 

 

 

 

 

 

 

 

    

  

Docker的使用及基本用法

原文:https://www.cnblogs.com/molson/p/13559029.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!