docker search centos   查系统镜像

docker pull docker.io/centos

进入容器

[root@git opt]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/tomcat8 latest 37e6b19c14e0 hours ago MB
gitalb-zh latest dd61a1ec3cdc days ago 1.72 GB
docker.io/twang2218/gitlab-ce-zh latest 1f71f185271a days ago 1.63 GB
docker.io/centos latest 2d194b392dd1 weeks ago MB
docker run -it docker.io/centos /bin/bash

安装tomcat

yum -y install tomcat......
代码路径: /usr/share/tomcat/webapps/ROOT/index.jsp
配置文件路径: /usr/share/tomcat/

把装好tomcat容器,生成镜像

[root@git opt]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a9717660d785 docker.io/tomcat8 "/usr/sbin/init" About an hour ago Up About an hour 0.0.0.0:888->8080/tcp tomcat8
[root@git opt]# docker commit a9717660d785 docker.io/tomcat8

用新镜像生成容器进行访问

[root@git opt]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/tomcat8 latest 37e6b19c14e0 26 hours ago 517 MB
gitalb-zh latest dd61a1ec3cdc 2 days ago 1.72 GB
docker.io/twang2218/gitlab-ce-zh latest 1f71f185271a 11 days ago 1.63 GB
docker.io/centos latest 2d194b392dd1 2 weeks ago 195 MB
docker run -itd -p 888:8080 --privileged=true --name tomcat8 docker.io/tomcat8 /usr/sbin/init   (注:参数-d 是后台运行)

结尾如果 /bin/bash 进入容器后无法启动服务,报错:Failed to get D-Bus connection: Operation not permitted
据说是centos7的BUG
所以这里需 /usr/sbin/init 进入容器后可以使用systemctl 命令
因为这样会把宿主机的dbus服务带入容器启动 [root@a9717660d785 /]# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 07:38 ? 00:00:00 /usr/sbin/init
root 17 1 0 07:38 ? 00:00:00 /usr/lib/systemd/systemd-journald
root 27 1 0 07:38 ? 00:00:00 /usr/sbin/sshd -D
dbus 28 1 0 07:38 ? 00:00:00 /bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
root 29 1 0 07:38 ? 00:00:00 /usr/lib/systemd/systemd-logind

如果想进入:

[root@git opt]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a9717660d785 docker.io/tomcat8 "/usr/sbin/init" About an hour ago Up About an hour 0.0.0.0:888->8080/tcp tomcat8
[root@git opt]# docker exec -it a9717660d785 bash

访问看效果:

docker—tomcat 报错:Failed to get D-Bus connection: Operation not permitted的更多相关文章

  1. 巨坑npm run dev 报错 终于找到正确答案 Error: EPERM: operation not permitted, open '/data/public/build/css/add.p

    Windows10环境 npm run dev 报错  终于找到正确答案 Error: EPERM: operation not permitted, open '/data/public/build ...

  2. docker pull报错failed to register layer: Error processing tar file(exit status 1): open permission denied

    近来在一个云主机上操作docker pull,报错如下: failed to register layer: Error processing ): open /etc/init.d/hwclock. ...

  3. Docker 内pip安装package报错: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'

    说来奇幻(对本菜来说, 经常遇到堪称奇幻的问题) 之前在docker里面各种安装都没问题, 也不知道什么引起的, 昨天晚上调试的时候卸载了一个包的版本,然后就安不上了. 宿主机安装依然各种流畅,唯独d ...

  4. maven发布到tomcat报错: Publishing failed Could not publish to the server. java.lang.IndexOutOfBoundsException

    eclipse中将maven项目发布到tomcat报错时: Publishing failed Could not publish to the server. java.lang.IndexOutO ...

  5. Tomcat报错: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/myApp]]

    Tomcat报错:严重: A child container failed during startjava.util.concurrent.ExecutionException: org.apach ...

  6. 第一次安装tomcat报错,出现failed to install tomcat8 service错误

    第一次安装tomcat报错,出现failed to install tomcat8 service错误(0) 一.一般情况下这种错误都是没有卸载干净造成的,安全卸载Tomcat的方法 (转载); ht ...

  7. docker启动报错iptables failed: -重建docker0网络恢复

    # docker启动报错 [root@localhost mysqlconf]# docker run -d -p 8080:8080 --link zookeeper:zookeeper -e du ...

  8. tomcat运行报错Failed to start component [StandardEngine[Catalina].StandardHost[localhost].

    tomcat运行报错Failed to start component [StandardEngine[Catalina].StandardHost[localhost].多半情况是找不到jar包 解 ...

  9. junit单元测试报错Failed to load ApplicationContext,但是项目发布到tomcat浏览器访问没问题

    junit单元测试报错Failed to load ApplicationContext,但是项目发布到tomcat浏览器访问没问题,说明代码是没问题的,配置也没问题.开始时怀疑是我使用junit版本 ...

随机推荐

  1. iOS用contenteditable滚动时,光标不会刷新定位的处理方法

    分析 iOS的 wkwebview 在滚动时会暂停许多动画,作为优化 解决思路 监听滚动事件,利用文档重绘即可刷新动画 ps:因为滚动有惯性,touchmove事件只能监听到手指松开的那一刻,所以只能 ...

  2. 18、nginx优化

    一.性能优化概述 基询imm能优化,那么在性能优化这一章,我们将分为如下几个方面做介绍 1.首先我们需要了解性能优化要考虑哪些方面. 2.然后我们需要了解性能优化必须要用到的压力测试工具ab. 3.最 ...

  3. c++的并发操作(多线程)

    C++11标准在标准库中为多线程提供了组件,这意味着使用C++编写与平台无关的多线程程序成为可能,而C++程序的可移植性也得到了有力的保证.另外,并发编程可提高应用的性能,这对对性能锱铢必较的C++程 ...

  4. 搭建内部NuGet服务

    简介 NuGet相当于Python中的pip,nodejs中的npm,用来管理.net/.net core的程序集版本,也叫包管理器.在框架化.模块化开发中使用nuget服务必不可少,尤其是在abp开 ...

  5. Fatal Error: Out of memory php内存溢出处理三种方法

    有时候我们在运行php程序的时候会发现 Fatal Error: Out of memory 这样的提示,这有可能是程序中用到了大量了变量和对象,导致分配的内存不够用. 修改php.ini文件里的me ...

  6. win10上使用自带的Hyper-V安装虚拟机

    Hyper-V管理器,新建虚拟机,安装了.iso系统,但启动报错,电脑上联想G40-70,都说在bios设置的security里开启硬件虚拟化选项,可我security里没有虚拟化相关选项, 后来在 ...

  7. gcc -DDEBUG

    编译方法: gcc -D(DEBUGNAME) -o execution_name execution_source_code.c 例如: gcc -DDEBUG -o quick_sort quic ...

  8. shell知识点(一)

    Shell1.概述Shell是一个命令行解释器,它接收应用程序/用户命令,然后调用操作系统内核还是一个功能相当强大的编程语言,易编写.易调试.灵活性强2.shell解析器查看linux提供的shell ...

  9. HTML中的      等6种空格标记

    HTML提供了5种空格实体(space entity),它们拥有不同的宽度,非断行空格( )是常规空格的宽度,可运行于所有主流浏览器.其他几种空格(      ‌‍)在不同浏览器中宽度各异.   它叫 ...

  10. 使用 mybatis-Generator 自动生成DAO、Model、Mapping相关文件

    1.Maven项目 2.配置generatorConfig.xml文件 3.在pom.xml中配置插件 2.generatorConfig.xml文件信息 <?xml version=" ...