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. JAVA网络编程入门

    JAVA网络编程入门 软件结构 C/S结构 B/S结构 无论哪一种结构,都离不开网络的支持.网络编程,就是在网络的条件下实现机器间的通信的过程 网络通信协议 网络通信协议:通信双方必须同时遵守才能完成 ...

  2. ubuntu16.04 Installing PHP 7.2

    //install sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt-get install php7.2 //C ...

  3. 爆路径写后门拿shell的一些姿势

    [PhpMyAdmin后台拿Shell]CREATE TABLE `mysql`.`xiaoma` (`xiaoma1` TEXT NOT NULL );INSERT INTO `mysql`.`xi ...

  4. 如何使用python生成gif

    如何使用python生成gif? 在我的文件夹里面有很多图片,我们如何将其合成一个gif呢?可以使用PIL模块,这个模块在我的"python图像处理"板块中有详细介绍. # -*- ...

  5. 关于STM32中printf函数的重定向问题

    printf函数一般是打印到终端的,stm32芯片调试中经常需要用到串口来打印调试信息,那能不能用串口实现类似windows的Console中的printf呢? 答案是肯定的,那就是printf函数的 ...

  6. Jenkins 入门系列--Jenkins 的安装配置

    写的我想吐血,累死了. 网页看着不爽的,自己去下载PDF.有问题请留言! Jenkins入门系列之--03PDF文档下载 第二章 Jenkins安装与配置 2 Jenkins安装 在最简单的情况下,J ...

  7. POJ - 2774 Long Long Message (后缀数组/后缀自动机模板题)

    后缀数组: #include<cstdio> #include<algorithm> #include<cstring> #include<vector> ...

  8. Kendo UI for jQuery使用教程:使用MVVM初始化(二)

    [Kendo UI for jQuery最新试用版下载] Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support ...

  9. 在服务端中,读取properties资源文件中的数据

    1.获取到资源的路径 2.读取数据 //properties文件对象 Properties properties = new Properties(); //通过HttpServletRequest ...

  10. Ruby笔记

    1.数组遍历方法总结 array = (1..10).to_a length = array.length length.times do t print "#{array[t]} &quo ...