关闭 x
IT技术网
    技 采 号
    ITJS.cn - 技术改变世界
    • 实用工具
    • 菜鸟教程
    IT采购网 中国存储网 科技号 CIO智库

    IT技术网

    IT采购网
    • 首页
    • 行业资讯
    • 系统运维
      • 操作系统
        • Windows
        • Linux
        • Mac OS
      • 数据库
        • MySQL
        • Oracle
        • SQL Server
      • 网站建设
    • 人工智能
    • 半导体芯片
    • 笔记本电脑
    • 智能手机
    • 智能汽车
    • 编程语言
    IT技术网 - ITJS.CN
    首页 » HTML5 »在 Mac OS X 上安装红帽容器开发工具包

    在 Mac OS X 上安装红帽容器开发工具包

    2015-05-24 00:00:00 出处:linux.cn
    分享

    容器技术很棒,它将会改变我们开发好传递软件的方式。当然也有一个批评此技术的人认为它并不安全和足够安全的在产品环境运行。

    随着 Red Hat Enterprise Linux 7.1 和 Red Hat Atomic 的登陆,企业和组织机构可以不用牺牲安全性和性能,也能拥抱这一新技术趋势。

    什么 Red Hat CDK

    CDK 是 Container Development Kit(容器开发包)的缩写,它能让开发者在他们的桌面系统上使用 Red Hat Atomic,不管他们所使用的是 Microsoft Windows ,Mac OS X 或者其他 Linux 的发行版。同boot2docker类似,CDK利用虚拟机来启动一个小的主机,它能运行基于 Red Hat Enterprise Linux 的容器。

    前置条件

    Red Hat 订阅 – 要安装 Red Hat CDK 你就得拥有一个激活了的 Red Hat Enterprise Linux 订阅, 假如没有,可以在 这里 进行申请和查看。 虚拟环境 – virtualBox (Mac/Windows) 或者 virt-manager (Linux) Vagrant – 用来创建和管理虚拟环境。

    从 Red Hat 消费者门户 下载下面这些东西。

    Red Hat 容器工具(Container Tools) 面向 VirtualBox 的 Red Hat Atomic Vagrant 盒子 或者 面向libvirt 的 Red Hat Atomic Vagrant 盒子。

    安装 Red Hat 容器开发包

    注意:在这之前你需要安装好虚拟化环境以及 Vagrant

    解压你下载的 cdk.zip 文件到主目录. 这样会创建 ~/cdk (/Users/username/cdk)

    $ unzip -d $HOME ~/Downloads/cdk-1.0-0.zip

    安装使用 Red Hat Vagrant 所需要的 Vagrant 插件. 第一个插件会花几分钟时间,Vagrant 可能会需要安装一些额外的gem文件。

    $ cd ~/cdk/plugins
    $ vagrant plugin install vagrant-registration-0.0.8.gem
    $ vagrant plugin install vagrant-atomic-0.0.3.gem

    验证插件是否已经安装好了:

    $ vagrant plugin list
    vagrant-atomic (0.0.3)
      - Version Constraint: 0.0.3
    vagrant-registration (0.0.8)
     - Version Constraint: 0.0.8

    将 RHEL Atomic 盒子添加到 Vagrant:

    $ vagrant box add --name rhel-atomic-7 ~/Downloads/rhel-atomic-virtualbox-7.1-0.x86_64.box

    启动 Atomic 主机

    为 docker 文件创建一个工作目录

    $ mkdir ~/containers && cd ~/containers

    为容器创建一个工作目录,并初始化 vagrant

    $ mkdir containers && cd containers
    $ vagrant init -m
    A `Vagrantfile` has been placed in this directory. You are now
    ready to `vagrant up` your first virtual environment! Please read
    the comments in the Vagrantfile as well as documentation on
    `vagrantup.com` for more information on using Vagrant.

    这一步会创建一个简单的 Vagrant 文件。打开它并像下面这样修改配置:

    Vagrant.configure(2) do |config|
      config.vm.box = "rhel-atomic-7"
      config.vm.hostname = "rhel-atomic-7-docker-host"
    
      config.vm.provider "virtualbox" do |vb|
        vb.customize ["modifyvm", :id, "--cpuexecutioncap", "50"]
        vb.memory = 4096
      end
    
      config.vm.provision "shell", inline: <<-SHELL
        sudo systemctl stop docker > /dev/null 2>&1
        sudo groupadd docker > /dev/null 2>&1
        sudo usermod -a -G docker vagrant
        sudo systemctl enable docker && sudo systemctl start docker
        sudo chown root:docker /var/run/docker.sock
        sudo systemctl enable docker && sudo systemctl start docker
      SHELL
    end

    我们现在已经做好了启动容器的准备。在机器的创建过程中,你将会看到是否想要注册系统的提示。回答 “Y” 就会要你输入RHN (Red Hat Network) 账户的用户名和密码.

    $ vagrant up
    Bringing machine 'default' up with 'virtualbox' provider...
    ==> default: Importing base box 'rhel-atomic-7'...
    ==> default: Matching MAC address for NAT networking...
    ==> default: Setting the name of the VM: containers_default_1432213616739_95846
    ==> default: Clearing any previously set network interfaces...
    ==> default: Preparing network interfaces based on configuration...
        default: Adapter 1: nat
    ==> default: Forwarding ports...
        default: 22 => 2222 (adapter 1)
    ==> default: Running 'pre-boot' VM customizations...
    ==> default: Booting VM...
    ==> default: Waiting for machine to boot. This may take a few minutes...
        default: SSH address: 127.0.0.1:2222
        default: SSH username: vagrant
        default: SSH auth method: private key
        default: Warning: Connection timeout. Retrying...
        default: 
        default: Vagrant insecure key detected. Vagrant will automatically replace
        default: this with a newly generated keypair for better security.
        default: 
        default: Inserting generated public key within guest...
        default: Removing insecure key from the guest if its present...
        default: Key inserted! Disconnecting and reconnecting using new SSH key...
    ==> default: Machine booted and ready!
    ==> default: Checking for guest additions in VM...
        default: No guest additions were detected on the base box for this VM! Guest
        default: additions are required for forwarded ports, shared folders, host only
        default: networking, and more. If SSH fails on this machine, please install
        default: the guest additions and repackage the box to continue.
        default: 
        default: This is not an error message; everything may continue to work properly,
        default: in which case you may ignore this message.
    ==> default: Setting hostname...
    ==> default: Registering box with vagrant-registration...
        default: Would you like to register the system now (default: yes)  [y|n] y
        default: Subscriber username: <your-rhn-username>
        default: Subscriber password: <password>==> default: Rsyncing folder: /Users/tqvarnst/containers/ => /home/vagrant/sync
    ==> default: Running provisioner: shell...
        default: Running: inline script

    测试你的安装

    $ vagrant ssh
    [vagrant@rhel-atomic-7-docker-host ~]$ docker ps
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
    [vagrant@rhel-atomic-7-docker-host ~]$ docker run -it rhel7.1 bash
    Unable to find image 'rhel7.1:latest' locally
    Pulling repository registry.access.redhat.com/rhel7.1
    10acc31def5d: Download complete 
    Status: Downloaded newer image for registry.access.redhat.com/rhel7.1:latest
    [root@ead3774c2b84 /]# cat /etc/redhat-release 
    Red Hat Enterprise Linux Server release 7.1 (Maipo)
    [root@ead3774c2b84 /]#

    按下 CTRL-P + CTRL-Q 可以离开你的容器

    [vagrant@rhel-atomic-7-docker-host ~]$ docker ps
    CONTAINER ID        IMAGE                                      COMMAND             CREATED              STATUS              PORTS               NAMES
    ead3774c2b84        registry.access.redhat.com/rhel7.1:7.1-4   "bash"              About a minute ago   Up About a minute                       focused_rosalind

    如下命令可以停掉或者删除容器

    [vagrant@rhel-atomic-7-docker-host ~]$ docker stop $(docker ps -q)
    ead3774c2b84
    [vagrant@rhel-atomic-7-docker-host ~]$ docker rm $(docker ps -aq)
    ead3774c2b84

    总结

    通过这个指南,你就可以有一个可以来使用基于 Red Hat Enterprise Linux 7.1 的容器的工作环境,不管你使用的是 Mac OS X ,Microsoft Windows 还是其它的Linux发行版。

    鸣谢

    特别要感谢 Pete Muir 在Vagrant设置上给我带来的支持和帮助。

    上一篇返回首页 下一篇

    声明: 此文观点不代表本站立场;转载务必保留本文链接;版权疑问请联系我们。

    别人在看

    正版 Windows 11产品密钥怎么查找/查看?

    还有3个月,微软将停止 Windows 10 的更新

    Windows 10 终止支持后,企业为何要立即升级?

    Windows 10 将于 2025年10 月终止技术支持,建议迁移到 Windows 11

    Windows 12 发布推迟,微软正全力筹备Windows 11 25H2更新

    Linux 退出 mail的命令是什么

    Linux 提醒 No space left on device,但我的空间看起来还有不少空余呢

    hiberfil.sys文件可以删除吗?了解该文件并手把手教你删除C盘的hiberfil.sys文件

    Window 10和 Windows 11哪个好?答案是:看你自己的需求

    盗版软件成公司里的“隐形炸弹”?老板们的“法务噩梦” 有救了!

    IT头条

    公安部:我国在售汽车搭载的“智驾”系统都不具备“自动驾驶”功能

    02:03

    液冷服务器概念股走强,博汇、润泽等液冷概念股票大涨

    01:17

    亚太地区的 AI 驱动型医疗保健:2025 年及以后的下一步是什么?

    16:30

    智能手机市场风云:iPhone领跑销量榜,华为缺席引争议

    15:43

    大数据算法和“老师傅”经验叠加 智慧化收储粮食尽显“科技范”

    15:17

    技术热点

    商业智能成CIO优先关注点 技术落地方显成效(1)

    用linux安装MySQL时产生问题破解

    JAVA中关于Map的九大问题

    windows 7旗舰版无法使用远程登录如何开启telnet服务

    Android View 事件分发机制详解

    MySQL用户变量的用法

      友情链接:
    • IT采购网
    • 科技号
    • 中国存储网
    • 存储网
    • 半导体联盟
    • 医疗软件网
    • 软件中国
    • ITbrand
    • 采购中国
    • CIO智库
    • 考研题库
    • 法务网
    • AI工具网
    • 电子芯片网
    • 安全库
    • 隐私保护
    • 版权申明
    • 联系我们
    IT技术网 版权所有 © 2020-2025,京ICP备14047533号-20,Power by OK设计网

    在上方输入关键词后,回车键 开始搜索。Esc键 取消该搜索窗口。