前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >2019-06-02 在MAC系统上通过Vagrant 安装 CentOS 并在虚拟机上安装docker

2019-06-02 在MAC系统上通过Vagrant 安装 CentOS 并在虚拟机上安装docker

作者头像
Albert陈凯
发布2019-06-03 08:36:04
8950
发布2019-06-03 08:36:04
举报
文章被收录于专栏:Albert陈凯Albert陈凯

实在搞不定可以用https://labs.play-with-docker.com/ 来玩玩就好了。

今天我打算练习docker,但还不影响MacOS的纯净性 计划使用虚拟机的方式进行练习,

结构如下,Mac -> vagrant -> VirtualBox Cent 7 -> Docker

这样做的目的是实验环境随时可一键删除,不影响使用的系统,

隔离了用户系统的影响,

不管是windows 还是 Mac 得到的演示结果是一致的

首先下载必要的软件

VirtualBox

https://www.virtualbox.org/wiki/Downloads

Vagrant

https://www.vagrantup.com/downloads.html

找到自己操作系统的版本

下载安装就不在这里详述了

打开终端工具执行命令 验证vagrant是否安装成功
代码语言:javascript
复制
AlbertMP:~ Albert$ vagrant
Usage: vagrant [options] <command> [<args>]

    -v, --version                    Print the version and exit.
    -h, --help                       Print this help.

Common commands:
     box             manages boxes: installation, removal, etc.
     cloud           manages everything related to Vagrant Cloud
     destroy         stops and deletes all traces of the vagrant machine
     global-status   outputs status Vagrant environments for this user
     halt            stops the vagrant machine
     help            shows the help for a subcommand
     init            initializes a new Vagrant environment by creating a Vagrantfile
     login
     package         packages a running vagrant environment into a box
     plugin          manages plugins: install, uninstall, update, etc.
     port            displays information about guest port mappings
     powershell      connects to machine via powershell remoting
     provision       provisions the vagrant machine
     push            deploys code in this environment to a configured destination
     rdp             connects to machine via RDP
     reload          restarts vagrant machine, loads new Vagrantfile configuration
     resume          resume a suspended vagrant machine
     snapshot        manages snapshots: saving, restoring, etc.
     ssh             connects to machine via SSH
     ssh-config      outputs OpenSSH valid configuration to connect to the machine
     status          outputs status of the vagrant machine
     suspend         suspends the machine
     up              starts and provisions the vagrant environment
     upload          upload to machine via communicator
     validate        validates the Vagrantfile
     version         prints current and latest Vagrant version
     winrm           executes commands on a machine via WinRM
     winrm-config    outputs WinRM configuration to connect to the machine

For help on any individual command run `vagrant COMMAND -h`

Additional subcommands are available, but are either more advanced
or not commonly used. To see all subcommands, run the command
`vagrant list-commands`.

下面开始用vagrant安装centOS7

代码语言:javascript
复制
# 创建一个目
mkdir -p ~/coding/docker/centos7
# 移动到当前目录
cd ~/coding/docker/centos7
# 查看当前目录
   pwd
# 初始化一个centos/7
  vagrant init centos/7
# 查看Vagrant 配置
 more Vagrantfile
# 启动
  vagrant up
# 登陆刚刚创建好了的 centos
  vagrant ssh

安装docker

https://docs.docker.com/install/linux/docker-ce/centos/#prerequisites

代码语言:javascript
复制
1  hostname
    2  ip addr
    3  exit
    4  ll
    5  sudo yum update
    6  exit
    7  sudo yum remove docker                   docker-client                   docker-client-latest                   docker-common                   docker-latest                   docker-latest-logrotate                   docker-logrotate                   docker-engine
    8  sudo yum install -y yum-utils   device-mapper-persistent-data   lvm2
    9  sudo yum-config-manager     --add-repo    https://download.docker.com/linux/centos/docker-ce.repo
   10  sudo yum install docker-ce docker-ce-cli containerd.io
   15  sudo systemctl start docker
   16  sudo docker run hello-world
   17  history

至此Docker就安装完成了

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019.06.02 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 首先下载必要的软件
    • VirtualBox
      • Vagrant
        • 打开终端工具执行命令 验证vagrant是否安装成功
      • 下面开始用vagrant安装centOS7
        • 安装docker
        相关产品与服务
        容器服务
        腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
        领券
        问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档