设为首页 收藏本站
查看: 471|回复: 0

[经验分享] docker_270

[复制链接]

尚未签到

发表于 2018-5-27 06:36:25 | 显示全部楼层 |阅读模式
1.Managing Containers
  login Atomic : ssh root@servera.pod0.example.com

-bash-4.2# docker search -s 1 fedora             ---above one
-bash-4.2# docker pull rhel7
-bash-4.2# docker load -i rhel-server-docker.tar.gz    ---load hard disk image
-bash-4.2# docker images
-bash-4.2# docker rmi fedora:rawhide
-bash-4.2# docker inspect rhel7
-bash-4.2# docker tag 10acc31def5d rhel7/latest:latest-kc4
-bash-4.2# docker save rhel7/latest:latest-kc4 > /var/tmp/kc4.tar
-bash-4.2# tar tvf /var/tmp/kcr.tar
-bash-4.2# docker run -p 8080:80 -ti rhel7/latest:latest-kc4  /bin/bash
-bash-4.2# exit
-bash-4.2# docker ps
-bash-4.2# docker kill c1b891b8f004
2.Building a Custom Image with Dockerfile

-bash-4.2# mkdir webserver-image
-bash-4.2# cd webserver-image
-bash-4.2# vi Dockerfile
            # Specify the base image to use
FROM registry.access.redhat.com/rhel7
MAINTAINER  Your Name
#Get the necessary software to run a web server
RUN yum --disablerepo='*'  --enablerepo=rhel-7-server-rpms install -y httpd
RUN echo 'container.example.com' > /etc/hostname
#create custom content (a personal index.html.file)
RUN echo 'Custom web server for student 0' >> /var/www/html/index.html

  -bash-4.2# docker build -t rhel_httpd1 .      ---run dockerfile and create custom image
-bash-4.2# docker run -p 80:80 -ti rhel_httpd1:latest /usr/sbin/httpd -DFOREGROUND
-bash-4.2# curl http://servera.pod0.example.com
-bash-4.2# cd ..   
-bash-4.2# cp -a webserver-image  webhome-image
-bash-4.2# cd webhome-image
-bash-4.2# vi Dockerfile
-bash-4.2# grep HOME Dockerfile

RUN echo "$HOME is where the heart is" >> /var/www/html/index.html
  -bash-4.2# docker build -t rhel_httpd2 .
-bash-4.2# docker run -p 80:80 -ti rhel_httpd2:latest /usr/sbin/httpd -DFOREGROUND
-bash-4.2# curl http://servera.pod0.example.com

3.Deploying a Private Container Image Registry
  ssh root@workstation.pod0.example.com
[root@workstation~]# yum install -y docker-registry


  • Use openssl to generate a private key
  [root@workstation~]# openssl genrsa -out /etc/pki/tls/private/self.key 1024


  •   Use the newly created private key to generate a self-signed certificate.
    [root@workstation~]# openssl req -new -key /etc/pki/tls/private/self.key -x509 -out /etc/pki/tls/certs/self.crt

    Country Name[XX]: US
    State or Province Name (full name)[]: North Carolina
    Locality Name [Default City]: Raleigh
    Organization Name[Default Company Ltd]: Example
    Organizational Unit Name(eg,section)[]:Training
    Common Name[]:workstation.pod0.example.com
    Email  Address[]: root@workstation.pod0.example.com
  •   Configure the docker-registry service to use the newly create self-signed certificate
      [root@workstation~]# cp /usr/lib/systemd/system/docker-registry.service /etc/systemd/system/
    [root@workstation~]# vi /etc/systemd/system/docker-registry.service

    ExecStart=/usr/bin/gunicorn --certfile /etc/pki/tls/certs/self.crt --keyfile /etc/pki/tls/private/self.key --access-logfile - --debug ...........
      [root@workstation~]# systemctl enable docker-registry.service
    [root@workstation~]# systemctl start docker-registry.service
    [root@workstation~]# systemctl status docker-registry.service
    [root@workstation~]# firewall-cmd --zone=public --add-port=5000/tcp
    [root@workstation~]# firewall-cmd --zone=public --add-port=5000/tcp --permanent
    -bash-4.2# hostname
    servera.pod0.example.com
    -bash-4.2# docker tag rhel7/latest:latest-kc4 workstation.pod0.example.com:5000/rhel_httpd1
    -bash-4.2# docker push workstation.pod0.example.com:5000/rhel_httpd1
    -bash-4.2# mkdir /etc/docker/certs.d/workstation.pod0.example.com:5000
    -bash-4.2# scp student@workstation.pod0.example.com:/etc/pki/tls/certs/self.crt /etc/docker/certs.d/workstation.pod0.example.com\:5000/ca.crt
    -bash-4.2# docker push workstation.pod0.example.com:5000/rhel_httpd1


chapter 5   deploying multitiered applications with containers
  -bash-4.2# hostname
servera.pod0.example.com
-bash-4.2# cd /var/tmp
-bash-4.2# curl -O http://classroom.example.com/materials/docker-images/webserver-all-in-one.tar.xz
-bash-4.2# docker load -i webserver-all-in-one.tar.xz
-bash-4.2# docker run -p 8080:80 -d rhel7:webserver-all-in-one /usr/local/bin/app_start
Firefox http://servera.pod0.example.com:8080/cgi-bin/action
[student@workstation~]# yum install -y httpd tools
[student@workstation~]# ab -n 100 -c 10 http://servera.pod0.example.com:8080/cgi-bin/action
-bash-4.2# docker exec -ti CONTAINER_ID tail -f /var/log/httpd/error_log
Use ab to simulate a DDos type of attack.

  -bash-4.2# cd /var/tmp
-bash-4.2# curl -O http://classroom.example.com/materials/docker-images/webserver.tar.xz
-bash-4.2# curl -O http://classroom.example.com/materials/docker-images/db.tar.xz
-bash-4.2# docker load -i webserver.tar.xz
-bash-4.2# docker load -i db.tar.xz
-bash-4.2# docker run -p 80:80 -d rhel7:webserver
-bash-4.2# docker run -p 3306:3306 -d rhel7:db
-bash-4.2# docker ps
-bash-4.2# docker inspect CONTAINER_ID
-bash-4.2# docker exec -ti CONTAINER_ID /bin/bash
bash-4.2# TERM=linux mysql -u root -p     ---redhat

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-481530-1-1.html 上篇帖子: 解决 Docker pull 出现的 error pulling image configurati 下篇帖子: Cloud in Action: Practice Docker and Networking
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表