Docker与OpenStack集成实战

简介:

1、计算节点安装Docker

root@compute2: ~# apt install docker.io -y

root@compute2:~# sh -c "echo deb https://get.docker.io/ubuntu docker main >> /etc/apt/sources.list.d/docker.list"

root@compute2:~# apt-get update

root@compute2:~# apt-get install lxc-docker

root@compute2: ~# apt install docker.io -y

查看当前版本

root@compute2:/var/lib/docker# docker --version

Docker version 1.12.0, build 8eab29e

root@compute2:~# docker -v

Docker version 1.12.0, build 8eab29e

root@compute2:~# dpkg -l | grep docker

rc  docker.io                                  1.11.2-0ubuntu5~16.04                                       amd64        Linux container runtime

ii  lxc-docker                                 1.9.1                                                       amd64        Linux container runtime

ii  lxc-docker-1.9.1                           1.9.1                                                       amd64        Linux container runtime

查找镜像

root@compute2:~# docker search ubuntu

dorapro/ubuntu                    ubuntu image                                    0                    [OK]

konstruktoid/ubuntu               Ubuntu base image                               0                    [OK]

uvatbc/ubuntu                     Ubuntu images with unprivileged user            0                    [OK]

2、下载Ubuntu镜像

root@compute2: ~#  docker pull ubuntu

Using default tag: latest

latest: Pulling from library/ubuntu

2f0243478e1f: Pull complete

d8909ae88469: Pull complete

820f09abed29: Pull complete

01193a8f3d88: Pull complete

Digest: sha256:8e2324f2288c26e1393b63e680ee7844202391414dbd48497e9a4fd997cd3cbf

Status: Downloaded newer image for ubuntu:latest

root@compute2:~# docker images -a

REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE

ubuntu                     latest              bd3d4369aebc        12 days ago         126.6 MB

ubuntu-1604-sleepy_kilby   latest              94c88d9d0023        3 weeks ago         126.4 MB

ubuntu                     <none>              f8d79ba03c00        3 weeks ago         126.4 MB

cmer81/centos7-openstack   latest              3317e0f4e0fb        7 months ago        322.2 MB

3、启动并登录Docker容器

root@compute2:~# docker run -i -t ubuntu

root@c0a0294d98d2:/# cat /etc/issue

Ubuntu 16.04.1 LTS \n \l

给容器设置root密码

[root@dfbc7c3db16b /]# passwd root

Changing password for user root.

New password:

Retype new password:

passwd: all authentication tokens updated successfully.

设置允许root密码登录

[root@dfbc7c3db16b /]# vi /etc/ssh/sshd_config

PermitRootLogin yes

PasswordAuthentication yes

SSH到容器中

root@compute2:~# ssh 172.17.0.3

root@172.17.0.3's password:

[root@dfbc7c3db16b ~]#

[root@dfbc7c3db16b ~]#

[root@dfbc7c3db16b ~]#

[root@dfbc7c3db16b ~]# ifconfig

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 172.17.0.3  netmask 255.255.0.0  broadcast 0.0.0.0

        inet6 fe80::42:acff:fe11:3  prefixlen 64  scopeid 0x20<link>

        ether 02:42:ac:11:00:03  txqueuelen 0  (Ethernet)

        RX packets 434  bytes 52434 (51.2 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 419  bytes 42782 (41.7 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536

        inet 127.0.0.1  netmask 255.0.0.0

        inet6 ::1  prefixlen 128  scopeid 0x10<host>

        loop  txqueuelen 1  (Local Loopback)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 0  bytes 0 (0.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@dfbc7c3db16b ~]#

退出Docker容器

root@76da79f898c3:/# exit

exit

4、在另一个docker主机查看目前运行的docker进程的ID

root@compute2:~# docker ps -a

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                        PORTS               NAMES

a8ffa3d75d46        ubuntu              "/bin/bash"         51 seconds ago      Exited (127) 42 seconds ago                       sleepy_kilby

aee77e7dec7b        ubuntu              "/bin/bash"         2 minutes ago       Exited (0) 53 seconds ago                         compassionate_hodgkin

c0a0294d98d2        ubuntu              "/bin/bash"         47 minutes ago      Exited (127) 38 minutes ago                       ecstatic_ritchie

5、将镜像保存为

root@compute2:~# docker commit a8ffa3d75d46 ubuntu-1604-sleepy_kilby

sha256:94c88d9d002364ed5b405357f6910fbc6fdddda917a07f99933a65e66e74fe99

6、将此镜像打包成一个文件

root@compute2:~# docker save ubuntu-1604-sleepy_kilby > /root/ubuntu-1604.tar

7、从终端直接启动容器

root@compute2:~# docker run -i -t -p 50001:22 ubuntu-1604-sleepy_kilby /bin/bash

nova-docker方案实践

安装novadocker

python-pip 有一个BUG,如果已安装python-pip,先删除,

root@compute2:~# apt-get remove python-pip

root@compute2:~#apt-get autoremove

root@compute2:~# easy_install -U pip

root@compute2:~# pip install -e git+https://github.com/stackforge/nova-docker#egg=novadocker

root@compute2:~# cd src/novadocker/

root@compute2:~/src/novadocker# python setup.py install

配置NOVA

root@compute2:~# vim /etc/nova/nova.conf

[DEFAULT]

compute_driver = novadocker.virt.docker.DockerDriver

创建/etc/nova/rootwrap.d/dockers.filters

# nova-rootwrap command filters for setting up network in the docker driver

# This file should be owned by (and only-writeable by) the root user

[Filters]

# nova/virt/docker/driver.py: 'ln', '-sf', '/var/run/netns/.*'

ln: CommandFilter, /bin/ln, root

配置Glance

root@controller:/etc/glance# vim glance-api.conf

[DEFAULT]

container_formats = ami,ari,aki,bare,ovf,docker

下载Docker镜像

查找适用于OpenStack的镜像

root@compute2:~# docker search openstack

NAME                                 DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED

krystism/openstack-keystone          An easy way to try openstack keystone service   7                    [OK]

continuse/openstack-controller       OpenStack Controller Service for CoreOS         5                    [OK]

centurylink/openstack-cli-wetty      This image provides a Wetty terminal with ...   4                    [OK]

cmer81/centos7-openstack             Centos7 image for openstack-cloudinit           2                    [OK]

continuse/openstack-nova-docker      OpenStack Nova-Docker Service for CoreOS        2                    [OK]

cosmicq/openstack-nova               (project not complete) The Nova (compute) ...   1                    [OK]

cosmicq/openstack-rabbitmq           (project not complete) RabbitMQ (AMQP) ser...   1                    [OK]

ennweb/openstack-controller          OpenStack Controller                            1                    [OK]

cosmicq/openstack-keystone           (project not complete) The Keystone (authe...   1                    [OK]

cosmicq/openstack-mariadb            (project not complete) MariaDB and PHPMyAd...   1                    [OK]

continuse/openstack-network          OpenStack Network (Neutron) Service for Co...   1                    [OK]

continuse/openstack-compute          OpenStack Compute Service for CoreOS            1                    [OK]

krystism/openstack-glance            An easy way to try openstack glance service     1                    [OK]

factual/docker-openstack-database    OpenStack Database (MariaDB)                    1                    [OK]

pataquets/openstack-dashboard                                                        0                    [OK]

colstrom/openstack-cli               OpenStack CLI                                   0                    [OK]

continuse/openstack-cinder           OpenStack Block Storage Service for CoreOS      0                    [OK]

alvaroaleman/openstack-horizon       A simple Docker image for the Openstack Ho...   0                    [OK]

pataquets/openstack-keystone                                                         0                    [OK]

pierrezemb/exherbo-openstack         Exherbo image generator for OpenStack           0                    [OK]

factual/docker-openstack-messaging   OpenStack Messaging service (RabbitMQ)          0                    [OK]

ennweb/openstack-compute             OpenStack Compute on Docker                     0                    [OK]

anguslees/openstack-tox                                                              0                    [OK]

gbraad/openstack-client              Container with the OpenStack client and 's...   0                    [OK]

jmcvea/openstack-client              OpenStack command line tools                    0                    [OK]

root@compute2:~#

root@compute2:~# docker pull cmer81/centos7-openstack

Using default tag: latest

latest: Pulling from cmer81/centos7-openstack

a3ed95caeb02: Pull complete

3286cdf780ef: Pull complete

889e0983d8b8: Pull complete

48ed448d00d6: Pull complete

0ebb5fe0f8ad: Pull complete

c93dc6f68ef1: Pull complete

cf8e344e8663: Pull complete

9827381c9ae3: Pull complete

8f1f6b35ea96: Pull complete

Digest: sha256:84b374fe2a8bf40a8716d79e5ea179b2fb28352e8a18fa49ddda2ab295bebe6e

Status: Downloaded newer image for cmer81/centos7-openstack:latest

root@compute2:~# docker save cmer81/centos7-openstack | glance --os-image-api-version 1 image-create --is-public=True --container-format=docker --disk-format=raw --name cmer81/centos7-openstack

+------------------+--------------------------------------+

| Property         | Value                                |

+------------------+--------------------------------------+

| checksum         | 114c19e55638a317b837ae73f6c8314c     |

| container_format | docker                               |

| created_at       | 2016-08-17T03:03:22.000000           |

| deleted          | False                                |

| deleted_at       | None                                 |

| disk_format      | raw                                  |

| id               | 521f5a87-22cc-4851-a812-dee1b17b5e46 |

| is_public        | True                                 |

| min_disk         | 0                                    |

| min_ram          | 0                                    |

| name             | cmer81/centos7-openstack             |

| owner            | f9027cccf7da4f2399c7fdf32e8776f0     |

| protected        | False                                |

| size             | 334179328                            |

| status           | active                               |

| updated_at       | 2016-08-17T03:03:28.000000           |

| virtual_size     | None                                 |

+------------------+--------------------------------------+

查找ubuntu镜像

root@compute2:~# docker search ubuntu

NAME                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED

ubuntu                            Ubuntu is a Debian-based Linux operating s...   4468      [OK]       

ubuntu-upstart                    Upstart is an event-based replacement for ...   65        [OK]       

rastasheep/ubuntu-sshd            Dockerized SSH service, built on top of of...   31                   [OK]

torusware/speedus-ubuntu          Always updated official Ubuntu docker imag...   27                   [OK]

ubuntu-debootstrap                debootstrap --variant=minbase --components...   25        [OK]       

nickistre/ubuntu-lamp             LAMP server on Ubuntu                           8                    [OK]

nuagebec/ubuntu                   Simple always updated Ubuntu docker images...   7                    [OK]

nickistre/ubuntu-lamp-wordpress   LAMP on Ubuntu with wp-cli installed            6                    [OK]

nimmis/ubuntu                     This is a docker images different LTS vers...   5                    [OK]

jordi/ubuntu                      Ubuntu Base Image                               1                    [OK]

admiringworm/ubuntu               Base ubuntu images based on the official u...   1                    [OK]

seetheprogress/ubuntu             Ubuntu image provided by seetheprogress us...   1                    [OK]

darksheer/ubuntu                  Base Ubuntu Image -- Updated hourly             1                    [OK]

life360/ubuntu                    Ubuntu is a Debian-based Linux operating s...   0                    [OK]

datenbetrieb/ubuntu               custom flavor of the official ubuntu base ...   0                    [OK]

konstruktoid/ubuntu               Ubuntu base image                               0                    [OK]

lynxtp/ubuntu                     https://github.com/lynxtp/docker-ubuntu         0                    [OK]

esycat/ubuntu                     Ubuntu LTS                                      0                    [OK]

widerplan/ubuntu                  Our basic Ubuntu images.                        0                    [OK]

croscon/ubuntu                    Crosconized Ubuntu                              0                    [OK]

teamrock/ubuntu                   TeamRock's Ubuntu image configured with AW...   0                    [OK]

smartentry/ubuntu                 ubuntu with smartentry                          0                    [OK]

ustclug/ubuntu                    ubuntu image for docker with USTC mirror        0                    [OK]

dorapro/ubuntu                    ubuntu image                                    0                    [OK]

webhippie/ubuntu                  Docker images for ubuntu                        0                    [OK]

下载镜像

root@compute2:~# docker pull ubuntu

Using default tag: latest

latest: Pulling from library/ubuntu

Digest: sha256:8e2324f2288c26e1393b63e680ee7844202391414dbd48497e9a4fd997cd3cbf

Status: Image is up to date for ubuntu:latest

把镜像上传到Glance中

root@compute2:~# docker save ubuntu | glance image-create --container-format=docker --disk-format=raw --name ubuntu-docer

+------------------+--------------------------------------+

| Property         | Value                                |

+------------------+--------------------------------------+

| checksum         | 364a6b81f4a3f5fb5c4a0e1d62395322     |

| container_format | docker                               |

| created_at       | 2016-08-17T02:46:58Z                 |

| disk_format      | raw                                  |

| id               | e2616723-b55d-48a6-9548-606f0da7dddb |

| min_disk         | 0                                    |

| min_ram          | 0                                    |

| name             | ubuntu-docer                         |

| owner            | f9027cccf7da4f2399c7fdf32e8776f0     |

| protected        | False                                |

| size             | 132096512                            |

| status           | active                               |

| tags             | []                                   |

| updated_at       | 2016-08-17T02:46:59Z                 |

| virtual_size     | None                                 |

| visibility       | private                              |

+------------------+--------------------------------------+

root@compute2:~# nova image-list

+--------------------------------------+-----------------------------------------+--------+--------+

| ID                                   | Name                                    | Status | Server |

+--------------------------------------+-----------------------------------------+--------+--------+

| 96872d33-73a1-4e1d-bc9e-5b4206a258af | CentOS-7-x86_64-GenericCloud            | ACTIVE |        |

| c8d224af-b3ed-42be-a29b-ea7295abf932 | Ubuntu16.04-server-clouding-powerpc64el | ACTIVE |        |

| e9b86672-f9d2-48f3-b57f-0320fc4a048f | Ubuntu16.04-xenial-server-cloud-amd64   | ACTIVE |        |

| 521f5a87-22cc-4851-a812-dee1b17b5e46 | cmer81/centos7-openstack                | ACTIVE |        |

| e2616723-b55d-48a6-9548-606f0da7dddb | ubuntu-docer                            | ACTIVE |        |

| ba5c1506-4389-42b5-acfb-849855b019b5 | ubuntu-server-clouding-amd64            | ACTIVE |        |

| b2170c9b-41da-4b55-a4ec-88b8b3fc528e | ubuntu1604-server-cloud-ppc64el         | ACTIVE |        |

| c94a41f5-10b2-43f8-ae5d-1c91886f6f94 | windows2012server-clouding              | ACTIVE |        |

+--------------------------------------+-----------------------------------------+--------+--------+

root@compute2:~# nova boot centos7-openstack --image 521f5a87-22cc-4851-a812-dee1b17b5e46 --nic net-id=a969f82e-b4cc-48cf-a04a-64923dc73b4a --flavor 22 --security-groups default --key key

+--------------------------------------+-----------------------------------------------------------------+

| Property                             | Value                                                           |

+--------------------------------------+-----------------------------------------------------------------+

| OS-DCF:diskConfig                    | MANUAL                                                          |

| OS-EXT-AZ:availability_zone          |                                                                 |

| OS-EXT-SRV-ATTR:host                 | -                                                               |

| OS-EXT-SRV-ATTR:hostname             | centos7-openstack                                               |

| OS-EXT-SRV-ATTR:hypervisor_hostname  | -                                                               |

| OS-EXT-SRV-ATTR:instance_name        | instance-0000070f                                               |

| OS-EXT-SRV-ATTR:kernel_id            |                                                                 |

| OS-EXT-SRV-ATTR:launch_index         | 0                                                               |

| OS-EXT-SRV-ATTR:ramdisk_id           |                                                                 |

| OS-EXT-SRV-ATTR:reservation_id       | r-3euaomoc                                                      |

| OS-EXT-SRV-ATTR:root_device_name     | -                                                               |

| OS-EXT-SRV-ATTR:user_data            | -                                                               |

| OS-EXT-STS:power_state               | 0                                                               |

| OS-EXT-STS:task_state                | scheduling                                                      |

| OS-EXT-STS:vm_state                  | building                                                        |

| OS-SRV-USG:launched_at               | -                                                               |

| OS-SRV-USG:terminated_at             | -                                                               |

| accessIPv4                           |                                                                 |

| accessIPv6                           |                                                                 |

| adminPass                            | KjbkCzV8VVn2                                                    |

| config_drive                         |                                                                 |

| created                              | 2016-08-17T03:23:21Z                                            |

| description                          | -                                                               |

| flavor                               | zoom.medium (22)                                                |

| hostId                               |                                                                 |

| host_status                          |                                                                 |

| id                                   | 41dad309-eb1a-4445-b1eb-81b87cd34d97                            |

| image                                | cmer81/centos7-openstack (521f5a87-22cc-4851-a812-dee1b17b5e46) |

| key_name                             | key                                                             |

| locked                               | False                                                           |

| metadata                             | {}                                                              |

| name                                 | centos7-openstack                                               |

| os-extended-volumes:volumes_attached | []                                                              |

| progress                             | 0                                                               |

| security_groups                      | default                                                         |

| status                               | BUILD                                                           |

| tenant_id                            | f9027cccf7da4f2399c7fdf32e8776f0                                |

| updated                              | 2016-08-17T03:23:21Z                                            |

| user_id                              | 957ba591d7824e0ab6e54d5c40e6be85                                |

+--------------------------------------+-----------------------------------------------------------------+

root@compute2:~# nova list

+--------------------------------------+-------------------+--------+------------+-------------+-----------------------------------+

| ID                                   | Name              | Status | Task State | Power State | Networks                          |

+--------------------------------------+-------------------+--------+------------+-------------+-----------------------------------+

| 41dad309-eb1a-4445-b1eb-81b87cd34d97 | centos7-openstack | ACTIVE | -          | Running     | private=10.1.1.80, 10.1.1.78      |

| 4f6c62b0-3917-4a4c-a017-bc57ff1a7e4d | ubuntu            | ACTIVE | -          | Running     | private=10.1.1.46

 



本文转自 OpenStack2015 51CTO博客,原文链接:http://blog.51cto.com/andyliu/1852267,如需转载请自行联系原作者

相关文章
|
8月前
|
人工智能 自然语言处理 API
快速集成GPT-4o:下一代多模态AI实战指南
快速集成GPT-4o:下一代多模态AI实战指南
622 101
|
7月前
|
监控 Kubernetes 安全
还没搞懂Docker? Docker容器技术实战指南 ! 从入门到企业级应用 !
蒋星熠Jaxonic,技术探索者,以代码为笔,在二进制星河中书写极客诗篇。专注Docker与容器化实践,分享从入门到企业级应用的深度经验,助力开发者乘风破浪,驶向云原生新世界。
776 51
还没搞懂Docker? Docker容器技术实战指南 ! 从入门到企业级应用 !
|
11月前
|
缓存 监控 安全
通义大模型与现有企业系统集成实战《CRM案例分析与安全最佳实践》
本文档详细介绍了基于通义大模型的CRM系统集成架构设计与优化实践。涵盖混合部署架构演进(新增向量缓存、双通道同步)、性能基准测试对比、客户意图分析模块、商机预测系统等核心功能实现。同时,深入探讨了安全防护体系、三级缓存架构、请求批处理优化及故障处理机制,并展示了实时客户画像生成和动态提示词工程。通过实施,显著提升客服响应速度(425%)、商机识别准确率(37%)及客户满意度(15%)。最后,规划了技术演进路线图,从单点集成迈向自主优化阶段,推动业务效率与价值持续增长。
567 8
|
11月前
|
运维 监控 数据可视化
容器化部署革命:Docker实战指南
容器化部署革命:Docker实战指南
|
8月前
|
人工智能 Java API
Java与大模型集成实战:构建智能Java应用的新范式
随着大型语言模型(LLM)的API化,将其强大的自然语言处理能力集成到现有Java应用中已成为提升应用智能水平的关键路径。本文旨在为Java开发者提供一份实用的集成指南。我们将深入探讨如何使用Spring Boot 3框架,通过HTTP客户端与OpenAI GPT(或兼容API)进行高效、安全的交互。内容涵盖项目依赖配置、异步非阻塞的API调用、请求与响应的结构化处理、异常管理以及一些面向生产环境的最佳实践,并附带完整的代码示例,助您快速将AI能力融入Java生态。
1395 12
|
11月前
|
存储 Kubernetes 监控
Docker与Kubernetes集成挑战及方案
面对这些挑战,并不存在一键解决方案。如同搭建灌溉系统需要考虑多种因素,集成Docker与Kubernetes也需要深思熟虑的规划、相当的技术知识和不断的调试。只有这样,才能建立起一个稳定、健康、高效的Docker-Kubernetes生态,让你的应用像花园中的植物一样繁荣生长。
435 63
|
10月前
|
供应链 测试技术 开发者
用 Docker 轻松部署 ERPNext 15:多场景实战指南
ERPNext 15 是一款功能全面的开源企业资源规划系统,结合 Docker 容器化部署,具备高效、灵活、低成本等优势。适用于小微企业数字化起步、多分支机构协同办公、开发者测试环境搭建、短期项目管理及企业内部培训等多种场景。模块化设计支持按需扩展,满足不同规模企业需求,是实现高效企业管理的理想选择。
用 Docker 轻松部署 ERPNext 15:多场景实战指南
|
12月前
|
人工智能 安全 Shell
Jupyter MCP服务器部署实战:AI模型与Python环境无缝集成教程
Jupyter MCP服务器基于模型上下文协议(MCP),实现大型语言模型与Jupyter环境的无缝集成。它通过标准化接口,让AI模型安全访问和操作Jupyter核心组件,如内核、文件系统和终端。本文深入解析其技术架构、功能特性及部署方法。MCP服务器解决了传统AI模型缺乏实时上下文感知的问题,支持代码执行、变量状态获取、文件管理等功能,提升编程效率。同时,严格的权限控制确保了安全性。作为智能化交互工具,Jupyter MCP为动态计算环境与AI模型之间搭建了高效桥梁。
773 2
Jupyter MCP服务器部署实战:AI模型与Python环境无缝集成教程
|
9月前
|
人工智能 自然语言处理 分布式计算
AI 驱动传统 Java 应用集成的关键技术与实战应用指南
本文探讨了如何将AI技术与传统Java应用集成,助力企业实现数字化转型。内容涵盖DJL、Deeplearning4j等主流AI框架选择,技术融合方案,模型部署策略,以及智能客服、财务审核、设备诊断等实战应用案例,全面解析Java系统如何通过AI实现智能化升级与效率提升。
767 0