doushu5805 2017-02-24 16:01
浏览 34

docker commit apache container to image带来麻烦

I have an ubuntu image where i have made some changes. Now i want to commit these changes to a new image but the problem now is, when I run the image the error says "PID[1] already running".

So, i thought that i could stop the apache in the container where i have made changes but this crashes (kills) the complete container and the changes are lost.

What i want:

Docker Ubuntu Image + Apache -> Container -> Some changes on the container -> Save the changes to a new Image -> Make a container out of the new image -> Have the "old image" with my changes in a new container, so i could start every time with my new image.

Are there any hints to get what i want?

Thank you!

  • 写回答

1条回答 默认 最新

  • douping3427 2017-02-24 16:11
    关注

    When you try to run two containers that expose the same port you will have an issue. So every time you try to run similar containers ( like in this case, you have two containers: old and new which do the same thing ) you need to reassign the ports. So -p 80:80 and -p 81:80.

    When new image is committed you can always use different tag ( of the same image ) which later you can use as reference.

    If you don't want to run two containers at once, just stop and rm the old container - don't worry, you will still have it's image, which you can spin anytime.

    Also, please remember you can't commit attached volumes.

    Hope that helps!

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!