0

While running a docker image named bobo:net with a python 3 script service.py:

docker run --entrypoint=python3 bobo:net service.py

Why is the image name specified in the middle of the actual command that is being ran?

Is the entrypoint only python3?

Why can't it simply be python3 service.py

What are the differences between entrypoint and command and what goes where?

AturSams
  • 7,568
  • 18
  • 64
  • 98
  • ... because that's how docker run was designed? – Paolo Mar 15 '23 at 07:34
  • @Paolo But what is the structure? I can't seem to find the accessible documentation tutorial or source code that explains this. python3 service.py is a valid Linux command. Obviously, python3 xyz service.py is not a valid command. What if tomorrow we need to run another command. What is the rule about where the docker image name goes? – AturSams Mar 15 '23 at 08:28
  • https://docs.docker.com/engine/reference/commandline/run/ the format is `docker run [OPTIONS] IMAGE [COMMAND] [ARG...]` – Paolo Mar 15 '23 at 08:29
  • So why is it [COMM [IMAGE] AND] in this case? Again: python3 service.py is a [COMMAND] bobo:net is an [IMAGE] – AturSams Mar 15 '23 at 08:30
  • 1
    It's not. `--entrypoint` is an option – Paolo Mar 15 '23 at 08:31
  • Are entrypoints not commands? Normally, any entrypoint is simply something that can be ran in Linux. – AturSams Mar 15 '23 at 08:32
  • 1
    `--entrypoint` is an option to docker run. So it has to come before the image name. Everything that comes to the image name is passed to the entrypoint – Paolo Mar 15 '23 at 08:33
  • Also see [What is the difference between CMD and ENTRYPOINT in a Dockerfile?](https://stackoverflow.com/questions/21553353/what-is-the-difference-between-cmd-and-entrypoint-in-a-dockerfile), though that doesn't discuss the `docker run` syntax. You should not usually need `docker run --entrypoint` (with its awkward syntax) and if you find yourself needing it you might redesign your Dockerfile to put the actual command in a `CMD` rather than `ENTRYPOINT`. Also consider tweaking your Python script so you don't need to name the `python3` interpreter explicitly. – David Maze Mar 15 '23 at 11:02

1 Answers1

0

Credit to Paolo:

It appears that you are:

  1. Limited to provide only one item in the --entrypoint option.
  2. After all the options, such as entrypoint, you specify your IMAGE name
  3. In the very end, you can specify arguments that are passed onto that --entrypoint option you specified

So essentially, if you want to run koprulu on braxis, with the docker image star:craft, you would type:

docker run --entrypoint=koprulu star:craft braxis

AturSams
  • 7,568
  • 18
  • 64
  • 98