Docker Community Forums

Share and learn in the Docker community.

Create image with series RUN commands but need to have "reboot" effect

I am creating a base image does requires several apt packages installed and some other, however during series of the RUN commands in original script, machine needs to reboot. How do I incorporate into Dockerfile that has a “reboot effect” so that subsequent commands can be executed successfully?
I am not sure, however doing those without reboot or something else might be causing problem when creating docker image. Thanks.,


FROM python:3.6
RUN <command1>
RUN <command2>
->> reboot here
RUN <command3>
RUN <command4>
->> reboot here
RUN <command5>
RUN <command6>
->> reboot here

There is no way to reboot and no need to do that. Each RUN creates a new layer which means each RUN starts a new container to execute the command. It means you have a new container start before each RUN. If you do something during build that affects the host system (which is a bad idea and I could not come up with an example) rebooting the container would not help.

What is the real problem? Why do you think you need a reboot?

Small addition: even though a fresh container based on the image layers crated so far is used, only the current RUN instruction is executed - nothing else, Containers don’t boot, and as such they can’t reboot.