微服务架构 ------ Ubuntu下Docker的安装

1.准备一个全新的Ubuntu环境

2.准备安装Docker及其依赖

  1. apt-get update 更新数据源
  2. apt-get -y install apt-transport-https ca-certificates curl software-properties-common  安装所需依赖
  3. curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -   安装CPG证书 
  4. add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"    增加阿里云镜像数据源
  5. apt-get update && apt-get install -y docker-ce  安装DOCKER
  6. docker version 验证docker

3.配置Docker镜像服务器

https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors  阿里的镜像加速器地址,前提是你要注册账号,免费的,每个人都有自己的镜像加速器地址

  1. cd /etc/docker/       touch daemon.json  创建json文件
  2. {
    "registry-mirrors": ["https://xxxxxxxx.mirror.aliyuncs.com"]
    }  替换为自己的镜像地址并写入文件

  3. systemctl daemon-reload
    systemctl restart docker    重启Docker

  4. Docker info   验证docker,查看信息中是否已经改成自己的镜像地址了

4.使用Docker镜像

  比如安装Tomcat    docker pull tomcat 

  安装成功之后的运行指令   docker run -p 8080:8080 tomcat  

  docker run -p  映射端口:内部端口 tomcat

猜你喜欢

转载自www.cnblogs.com/zmeRecord/p/11802223.html