博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
日常运维之持续集成docker测试环境
阅读量:3721 次
发布时间:2019-05-22

本文共 4616 字,大约阅读时间需要 15 分钟。

 

运行第一个容器

[root@localhost ~]# docker run -i -t centos /bin/bashUnable to find image 'centos:latest' locallylatest: Pulling from library/centos8ba884070f61: Pull complete Digest: sha256:8d487d68857f5bc9595793279b33d082b03713341ddec91054382641d14db861Status: Downloaded newer image for centos:latest[root@dd77efe3aa68 /]# 

查看当前系统中容器的列表

[root@localhost ~]# docker ps -a #查看当前中容器的列表CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                          PORTS               NAMESdd77efe3aa68        centos              "/bin/bash"              2 minutes ago       Exited (0) About a minute ago                       determined_lehmann88b7cea2ef07        nginx               "/bin/bash"              2 weeks ago         Exited (130) 2 weeks ago                            objective_gagarin780086dba00d        httpd               "httpd-foreground"       2 weeks ago         Exited (0) 2 weeks ago                              zen_fermi7500dd5b88c9        nginx               "nginx -s reload"        2 weeks ago         Exited (1) 2 weeks ago                              nostalgic_keller31a038906506        nginx               "nginx -g 'daemon of…"   2 weeks ago         Exited (0) 2 weeks ago                              flamboyant_lamarr44316cfd52e9        ubuntu:15.10        "/bin/sh -c 'while t…"   2 weeks ago         Exited (137) 2 weeks ago                            adoring_chatterjee5da8d136bf33        ubuntu:15.10        "bin/sh 'while true;…"   2 weeks ago         Exited (127) 2 weeks ago                            compassionate_shirley86347adc606e        ubuntu:15.10        "bin/sh 'while true;…"   2 weeks ago         Exited (127) 2 weeks ago                            infallible_dhawan9835c743b019        ubuntu:15.10        "/bin/bash"              2 weeks ago         Exited (0) 2 weeks ago                              gracious_wescoff4345d801c414        ubuntu:15.10        "/bin/echo hello"        2 weeks ago         Exited (0) 2 weeks ago                              modest_meitner387c0af7b665        ubuntu:15.10        "/bin/echo hello"        2 weeks ago         Exited (0) 2 weeks ago                              stupefied_archimedesb7b7d8f0a788        nginx               "nginx -g 'daemon of…"   2 weeks ago         Exited (137) 11 days ago                            rik_nginx
[root@localhost ~]# docker ps #当前正在运行的容器CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

给容器命名

[root@localhost ~]# docker run --name fleming_test -i -t centos /bin/bash[root@569134b8fedd /]#

启动停止的容器

[root@localhost ~]# docker start fleming_test #启动停止的容器fleming_test

附着到正在运行的容器

[root@localhost ~]# docker attach fleming_test[root@569134b8fedd /]#

列出镜像

[root@localhost ~]# docker imagesREPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
8dce45f00be0 2 weeks ago 88.9MBnginx latest bb776ce48575 3 weeks ago 109MBhttpd latest d4a07e6ce470 4 weeks ago 132MBcentos latest 9f38484d220f 7 weeks ago 202MBubuntu latest 94e814e2efa8 7 weeks ago 88.9MBhello-world latest fce289e99eb9 4 months ago 1.84kBubuntu 15.10 9b9cb95443b5 2 years ago 137MBtraining/webapp latest 6fae60ef3446 3 years ago 349MB

创建测试docker镜像

创建一个要修改的定制容器

[root@localhost docker]# docker run -i -t centos /bin/bash #创建一个容器[root@localhost docker]# docker ps -l -q #得到刚创建容器的ide3b2a7c3b01f

用本地系统做成的镜像新建测试容器

[root@localhost ~]# docker run -d -p 231:22 --name jason centos7 /usr/sbin/sshd -D //启动容器,并绑定容器端口22到宿主主机, 可以有多个-p 绑定多个端口,例如22端口让远程客户端连接,8080 可以访问容器内tomcat[root@localhost ~]# ssh root@192.168.0.252 -p 220The authenticity of host '[192.168.0.252]:220 ([192.168.0.252]:220)' can't be established.ECDSA key fingerprint is SHA256:8lY/a8uaXKoaGTVyun4LSXzClraZ5AiodB1kKarSNIE.ECDSA key fingerprint is MD5:74:fa:33:b5:06:e9:0c:c1:dd:80:84:1b:2e:38:33:6b.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '[192.168.0.252]:220' (ECDSA) to the list of known hosts.root@192.168.0.252's password: Last login: Mon May  6 10:45:39 2019[root@faff97aef1d1 ~]# ifconfigeth0: flags=4163
mtu 1500 inet 172.17.0.3 netmask 255.255.0.0 broadcast 172.17.255.255

通过xshell登录到自己的容器即可。在容器中操作和在centos7中操作是一样的。Xshell登录容器方式如下

 

转载地址:http://hadnn.baihongyu.com/

你可能感兴趣的文章
Zookeeper启动报错 Starting zookeeper ... already running as process 5688.
查看>>
CenterOs7 安装MySQL数据库
查看>>
CenterOS的Hive环境的搭建日志及可能出现的问题和解决方法
查看>>
SSM 严重: 子容器启动失败Failed to start component [StandardEngine[Catalina].StandardHost[localhost]
查看>>
NodeJs的Http服务器的搭建
查看>>
NodeJs使用npm安装第三方模块与moment模块进行时间格式化
查看>>
NodeJs 服务端渲染 art-template 与 CommonJS 的模块规范
查看>>
Hive 数据库操作(HQL语法详解)
查看>>
Java Xml 操作之 dom4j 详解和实现一个xml存储的学生管理系统
查看>>
Java8 详解
查看>>
Postman 接口测试
查看>>
VueCli 脚手架详解(从安装到实际运用)
查看>>
ElementUI项目的搭建和简介
查看>>
ElementUI+springboot 项目实战前后端分离(用户管理系统的开发)
查看>>
SpringBoot 简介和第一个项目
查看>>
mybatis插件篇之generator快速生成实体类以及其文件详解
查看>>
Springboot+vue 将数据导出成Excel文件(POI4.0)
查看>>
vue+elementui 如何刷新整个界面
查看>>
Vue全家桶之VueX详解
查看>>
使用 Vue+ElementUi 实现省市联动效果
查看>>