0

As we know Podman is dockerless, it does not have a daemon as docker.

In docker I'm able to run docker command by adding a volume in docker run -v /var/run/docker.sock:/var/run/docker.sock, with that the container can restart itself from inside with bash script.

Is there any solution to do the same thing in Podman, to run podman restart container within the container?

cht_usr
  • 119
  • 1
  • 8

1 Answers1

0

I would not give programs access to the Docker socket (and unlimited root-level access over the host) just to restart if something goes wrong.

If you determine there's a problem and your program can't keep running, it can just exit (calling something like exit() or sys.exit() or throwing an exception that doesn't get handled). When the main container process exits, it will trigger the container restart policy, which can cause the container to restart. podman run has an almost identical --restart option.

podman run --restart=on-failure ... my-image

You also might think about how you'd approach this problem if a container wasn't involved. If you need to reload your configuration, or re-exec your own binary, or have a developer-oriented non-production live-reloading environment, those same approaches will work equally well in a container or not, and wouldn't require a Docker socket.

David Maze
  • 130,717
  • 29
  • 175
  • 215
  • I agree with you, it is not recommended to give much access to the container. But exit or sys.exit will not stop the process of the container or kill it. – cht_usr Aug 19 '20 at 11:08