Docker + shipyard 测试 1 测试拓扑: (点小图查看大图)
•从镜像运行两个apache应用,测试服务访问 •安装shipyard容器管理程序,测试管理两台主机及container
3 测试过程 # Stopping Docker and removing docker0 $ sudo service docker stop $ sudo ip link set dev docker0 down $ sudo brctl delbr docker0 创建需要的网桥: $ sudo brctl addbr docker0 $ sudo ip addr add 10.0.1.197/24 devbridge0 $ sudo ip link set dev docker0 up $ ip addr show docker0 修改eth网卡使桥接生效: 修改需要通信的eth网卡,模式改为BRIDGE=bridge,并重启网络;ifconfig观察桥接是否生效并启用。
3.2 第一部分 # sudo yum install docker # sudo service docker start # sudo chkconfig docker on 创建非root用户mds,运行docker: # sudo usermod -a -G docker mds 拉取centos的docker镜像: # docker pull centos 查看拉取的docker镜像: # docker images 运行一个centos6docker镜像:
bash-4.1# yum -y install httpd bash-4.1# service httpd start bash-4.1# chkconfig httpd on 退出当前容器: bash-4.1# exit 重新封装该容器,创建镜像: # Docker commit b1bd49907d55 httpd 生成新镜像:
# docker run –i–t 55a05053732c /bin/bash bash-4.1#ifconfig eth0 查看IP地址:10.0.1.3 bash-4.1#service httpd start bash-4.1#[ctrl+q] 切出当前容器 # docker run –i–t 55a05053732c /bin/bash bash-4.1#ifconfig eth0 查看IP地址:10.0.1.4 bash-4.1#service httpd start bash-4.1#[ctrl+q] 操作步骤一样,但是新的容器会生成不同的containerID,查看已创建的容器:
http://10.0.1.3/
# docker pull shipyard/shipyard # docker images 查看images id # docker run –i –t 30e0b59613ff /bin/bash 运行shipyard服务 root@029b8401c5a0:/app# ifconfig 查看IP地址10.0.1.2 root@029b8401c5a0:/app# sudo pythonmanage.py runserver 0.0.0.0:8000 root@029b8401c5a0:/app# netstat -ant | grep 8000 查看服务状态 tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN 在两台host下载shipyard/agent,向shipyard注册host: # wget https://github.com/shipyard/shipyard-agent/releases/download/v0.3.2/shipyard-agent # ./shipyard-agent -url http://10.0.1.2:8000 –register # ./shipyard-agent -url http://10.0.1.2:8000 –key 1234567890qwertyuiop 登录shipyard管理端: Username: admin Password: shipyard
(点小图查看大图)
分别查看4500、4243端口是否被监控 关闭host防火墙,关闭docker服务,并执行以下命令; /usr/bin/docker -d -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock 之后重新启用docker,重复上述部署操作。
(责任编辑:IT) |