Skip to content
This repository has been archived by the owner on Aug 14, 2020. It is now read-only.

Handle Entrypoint and Cmd correctly #20

Merged
merged 1 commit into from
Feb 13, 2015

Conversation

iaguis
Copy link
Member

@iaguis iaguis commented Feb 11, 2015

Use Entrypoint + Cmd when both are present or just Cmd when Entrypoint
is not present.

Since non-absolute paths are not allowed by the spec, if the resulting
command is not absolute we fall back to running it with "/bin/sh -c".

Fixes #14

return nil
}
command = append(entrypoint, cmd...)
// non-absolute paths are not allowed, fallback to "/bin/sh -c command"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Starting to feel like we should have a means to provide warnings during the conversion process when things like this happen, thoughts? (In the real world this would probably very rarely cause problems since having /bin/sh in Docker images is a really common pattern, but would be good practise to give people some hint that we are doing this kind of translation and the produced image is potentially non-functional)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could warn with something like Exec is not an absolute path, using "/bin/sh -c EXEC". The resulting ACI could be non-functional.

This will be printed for each layer that we convert so it might be too verbose, especially if we're squashing. We could accumulate the warnings and print only one of each at the end. Something like:

Warnings found when converting the image. The resulting ACI could be non-fuctional:
        Exec is not an absolute path, using "/bin/sh -c EXEC"
        Docker User is empty, assuming root

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, printing is less than ideal since this is a library. Maybe we could allow callers to pass in something to record warnings. Not sure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's follow up with that later, filed #24

// this can't fail because the old name is legal
nameWithoutLayerID, _ := types.NewACName(strings.Split(manifest.Name.String(), "-")[0])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh, why was this necessary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every layer's name has the docker layerID at the end, this strips it from the squashed image name. It was wrong because the image name can have dashes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll put it in another PR

Use Entrypoint + Cmd when both are present or just Cmd when Entrypoint
is not present.

Since non-absolute paths are not allowed by the spec, if the resulting
command is not absolute we fall back to running it with "/bin/sh -c".
@iaguis
Copy link
Member Author

iaguis commented Feb 13, 2015

Since we have #24 now, I'm merging this.

iaguis added a commit that referenced this pull request Feb 13, 2015
Handle Entrypoint and Cmd correctly
@iaguis iaguis merged commit 2538c2a into appc:master Feb 13, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

set default exec from ENTRYPOINT and CMD
2 participants