Skip to content

images, README.md: Remove misleading and redundant CMD and update the requirements around ENTRYPOINT - #940

Merged
debarshiray merged 3 commits into
containers:mainfrom
debarshiray:wip/rishi/images-remove-cmd
Dec 1, 2021
Merged

debarshiray merged 3 commits into
containers:mainfrom
debarshiray:wip/rishi/images-remove-cmd

Conversation

@debarshiray

@debarshiray debarshiray commented Nov 30, 2021 •

Copy link
Copy Markdown
Member

@softwarefactory-delete-me

Copy link
Copy Markdown

Build succeeded.

@martymichal martymichal added the 2. Images Images for creating toolbox containers label Nov 30, 2021
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Dec 1, 2021
@debarshiray debarshiray changed the title images: Remove misleading and redundant CMD images, README.md: Remove misleading and redundant CMD and update the requirements around ENTRYPOINT Dec 1, 2021
There's no need to specify a CMD in a Toolbox image because it's
specified by 'toolbox create', through 'podman create', when creating a
container.

A CMD was specified [1] because the Fedora Container Guidelines
requires it [2]. The idea behind the guidelines is that the right
thing should happen when one runs:
  $ podman run <image>

However, that only makes sense for images targeting single service
containers. Toolbox containers and images are different - they are not
meant to be used like that to run a single one-off service.

Conceptually, 'running' a Toolbox container is expected to provide the
user with a reasonable interactive command line experience. Arguably,
that means offering something like /bin/bash, not /bin/sh.

Also, note that when the CMD was introduced [1], Toolbox containers
were actually created, through 'podman create', with /bin/sh as their
entry points. So, it did make some sense. However, things have changed
since then [3]. The entry point is now 'toolbox init-container'. It's
not possible to mention it in the Toolbox image because the
/usr/bin/toolbox binary isn't present in the image, and it's not meant
to be present.

Therefore, today, /bin/sh is simply not the right fit for a Toolbox
image's CMD. A better option would be /bin/bash.

Note that the fedora base images have their CMD set to /bin/bash, which
is inherited by the fedora-toolbox images.

So, there are two options. Either repeat the same CMD in the
fedora-toolbox images and satisfy the guidelines, or take some
liberties and let the CMD be inherited from the fedora base images.

This commit takes the latter option. People tend to use the
fedora-toolbox images as the starting point for other custom Toolbox
images, sometimes for other operating system distributions. It's
better to keep them minimal to avoid implying extra requirements. In
this case, the CMD is an abstract concept, and the actual entry point
is 'toolbox init-container' as specified by 'toolbox create'.
Specifying /bin/bash might discourage people from creating custom
images that are only meant to have /bin/zsh.

Also, note that the current CMD was actually '/bin/sh -c /bin/sh', not
/bin/sh. Unless a CMD is specified as an array of command line
arguments, it's passed as a single argument to '/bin/sh -c' [4]. So,
this:
  CMD foo bar

... is the same as:
  CMD [ "/bin/sh", "-c", "foo bar" ]

Only the images for currently maintained Fedoras (ie., 34 and 35) were
updated.

This reverts commit 5cc2678.

[1] Commit 5cc2678

[2] https://docs.fedoraproject.org/en-US/containers/guidelines/creation/

[3] Commit 8b84b5e
    containers#160

[4] https://docs.docker.com/engine/reference/builder/#cmd

containers#885
@debarshiray
debarshiray force-pushed the wip/rishi/images-remove-cmd branch from 1a1d9d1 to 2d56a8a Compare December 1, 2021 00:09
@softwarefactory-delete-me

Copy link
Copy Markdown

Build failed.

@debarshiray

Copy link
Copy Markdown
Member Author

recheck

@softwarefactory-delete-me

Copy link
Copy Markdown

Build succeeded.

@debarshiray
debarshiray merged commit 2d56a8a into containers:main Dec 1, 2021
@debarshiray
debarshiray deleted the wip/rishi/images-remove-cmd branch December 1, 2021 12:39
@martymichal martymichal added this to the Release 0.1.0 milestone Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2. Images Images for creating toolbox containers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants