建立自己的形象后运行码头工人 [英] Run docker after building own image

查看:158
本文介绍了建立自己的形象后运行码头工人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在上一篇文章之后,建议创建我自己的Docker镜像,我想用红宝石制作jenkins,所以我的docker文件看起来像

  FROM jenkins 
FROM ruby​​:2.3.0

我运行 docker build -t jenkins_ruby。



它正确构建,当我执行 docker时,我可以看到图像图片

  REPOSITORY TAG IMAGE ID CREATED SIZE 
jenkins最新77bd697ef2c3 5天前710.1 MB
jenkins_ruby最新1653f4c3a826 8天前729 MB
ruby​​最新1653f4c3a826 8天前729 MB

所以我想在容器中运行这个图像 docker run -p 8080:8080 jenkins_ruby



但我得到切换到检查模式。



我期待g可以去 ipaddress:8080 并查看jenkins控制台



我错过了什么吗? p>

谢谢

解决方案

Dockerfile不能有多个 FROM s。



这种基本上将两个图像合并在一起的功能不能在单个Docker文件中完成。所有这一切真的发生在这里,它将拉取 jenkins:最新的图像,拉$ ruby​​:2.3.0 image然后用 jenkins_ruby 标记 ruby​​ 图像。没有合并发生,您可以看到,与图像最终大小也一样, jenkins_ruby 的大小与 ruby​​



有一个Github问题来备份这个这里


After a previous post it was suggested to create my own Docker image, I wanted to have jenkins with ruby, so my dockerfile looks like

FROM jenkins
FROM ruby:2.3.0

I run docker build -t jenkins_ruby .

It builds correctly and i can see the image when i do docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
jenkins             latest              77bd697ef2c3        5 days ago          710.1 MB
jenkins_ruby        latest              1653f4c3a826        8 days ago          729 MB
ruby                latest              1653f4c3a826        8 days ago          729 MB

So i then want to run this image in a container docker run -p 8080:8080 jenkins_ruby

but i get Switch to inspect mode.

I was expecting to be able to go to ipaddress:8080 and see the jenkins console

Have i missed something?

Thanks

解决方案

A Dockerfile cannot have multiple FROMs.

This type of functionality to essentially merge two images together cannot be done in a single Dockerfile. All that's really happening here is that it will pull the jenkins:latest image, pull the ruby:2.3.0 image and then tag the ruby image with jenkins_ruby. There is no merging occurring, you can see that with the image final sizes too, jenkins_ruby has an identical size to ruby.

There's a Github issue to back this up here.

这篇关于建立自己的形象后运行码头工人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆