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

Support OPT1, OPT2 in install/run command #65

Merged
merged 1 commit into from
Jul 2, 2015

Conversation

sub-mod
Copy link
Contributor

@sub-mod sub-mod commented Jun 16, 2015

@rhatdan

The Labels look like below.
LABEL RUN docker run -it --rm ${OPT1} --privileged -v pwd:/atomicapp -v /run:/run -v /:/host --net=host --name ${NAME} -e NAME=${NAME} -e IMAGE=${IMAGE} ${IMAGE} -v ${OPT2} run ${OPT3} /atomicapp

LABEL STOP docker run -it --rm ${OPT1} --privileged -v pwd:/atomicapp -v /run:/run -v /:/host --net=host --name ${NAME} -e NAME=${NAME} -e IMAGE=${IMAGE} ${IMAGE} -v ${OPT2} stop ${OPT3} /atomicapp

LABEL INSTALL docker run -it --rm ${OPT1} --privileged -v pwd:/atomicapp -v /run:/run --name ${NAME} -e NAME=${NAME} -e IMAGE=${IMAGE} ${IMAGE} -v ${OPT2} install ${OPT3} --destination /atomicapp /application-entity

Usage:
atomic install --opt1="-p :5000" --opt2="-d" submod/guestbookphp-app
used in projectatomic/atomicapp#152
cockpit-project/cockpit#2474

@goern
Copy link
Contributor

goern commented Jun 17, 2015

can we provide a default to RUNARGS via a LABEL in a Dockerfile? Or should such a default be moved to the INSTALL/RUN LABEL?

@sub-mod sub-mod changed the title Support RUNARGS option WIP: Support RUNARGS option Jun 17, 2015
@sub-mod
Copy link
Contributor Author

sub-mod commented Jun 17, 2015

@goern can you give an example
i dont think we can avoid putting RUNARGS in install/run labels

@vpavlin
Copy link

vpavlin commented Jun 17, 2015

LABEL RUN docker run ... IMAGE RUNARGS /project
LABEL RUNARGS -v
atomic run $image
if not args.runargs:
  runargs = getLabel("RUNARGS")

Basically baing able to provide a default RUNARGS in LABELS so that we have a default behaviour specified and user can override it easily

@rhatdan
Copy link
Member

rhatdan commented Jun 18, 2015

I have been asked to put in multiple of these.

For example some people want to put args before the image and some after. Should it just be OPTION1, OPTION2, OPTION3?

atomic run --opt1 "-b foobridge" --opt2 "--ti"

LABEL RUN "docker ${opt1} run ${opt2} -n ${NAME} ${IMAGE}

@rhatdan
Copy link
Member

rhatdan commented Jun 18, 2015

This would allow users to specify multiple options where the command could take options.

@rhatdan
Copy link
Member

rhatdan commented Jun 18, 2015

I have a nice patch that I am about to accept that would just set environment variables and would eliminate the need to do replacements.

@sub-mod
Copy link
Contributor Author

sub-mod commented Jun 22, 2015

@rhatdan can you please share the patch

@sub-mod sub-mod closed this Jun 22, 2015
@sub-mod sub-mod reopened this Jun 22, 2015
@rhatdan
Copy link
Member

rhatdan commented Jun 22, 2015

@sub-mod The patch has been merged into docker.

Now we need a patch to allow --opt1, --opt2, --opt3 patch.

@sub-mod
Copy link
Contributor Author

sub-mod commented Jun 22, 2015

@rhatdan I am working on it now.
Can you please give me the docker patch PR

@bexelbie
Copy link
Contributor

@sub-mod I believe that @rhatdan may have been referencing #66

@sub-mod
Copy link
Contributor Author

sub-mod commented Jun 23, 2015

@bexelbie thanks, i tried that .It doesnt work for me. Has anyone tried that ? @rhatdan

@bexelbie
Copy link
Contributor

@sub-mod can you be more specific about what isn't working? The substitution seems to be working fine.

@sub-mod sub-mod changed the title WIP: Support RUNARGS option Support RUNARGS option Jun 23, 2015
@sub-mod sub-mod changed the title Support RUNARGS option Support OPT1, OPT2 in install/run command Jun 23, 2015
@sub-mod
Copy link
Contributor Author

sub-mod commented Jun 23, 2015

@rhatdan kindly review.
This works for me,

@rhatdan
Copy link
Member

rhatdan commented Jun 25, 2015

Merge the two pull requests together, and I think we should only set the environment variable if the options are used. Perhaps we should have three also.

opt1, opt2, opt3.

We should not be mentioning nulecule in the man pages. I think these options should be available for run, install and uninstall, Can be used to pass arguments to the LABEL RUN|INSTALL|UNINSTALL as ${opt1}. Then we should show an example for each man page.

LABEL RUN docker run -d ${opt1} -t ${NAME} ${IMAGE} ${opt2} --foobar ${opt3}

@purpleidea
Copy link

Without understanding all the specifics of this patch (since I didn't need it) it seems this might be similar to the feature needed for a spc puppet apply container for example.

@sub-mod
Copy link
Contributor Author

sub-mod commented Jun 30, 2015

@rhatdan kindly review

@rhatdan
Copy link
Member

rhatdan commented Jul 1, 2015

How about we change

 +    installp.add_argument("--opt3", dest="opt3", help="additional arguments to be passed for install Sub Command.") 

to

 +    installp.add_argument("--opt3", dest="opt3", help="additional arguments to be passed as ${OPT3} for install Sub Command.") 

For each --opt command.

@sub-mod
Copy link
Contributor Author

sub-mod commented Jul 2, 2015

@rhatdan kindly review

@rhatdan
Copy link
Member

rhatdan commented Jul 2, 2015

I think --opt1, --opt2 should be options of atomic run, atomic install, atomic uninstall.

Not just atomic.

It looks like you made --opt3 specific to each subcommand. These make no sense to separate out.

atomic run --opt1 "-d"
is better then

atomic --opt1 "-d" run

@sub-mod
Copy link
Contributor Author

sub-mod commented Jul 2, 2015

here is an example
atomic --opt1="-p :5000" --opt2="-d" install --opt3="--update" submod/guestbookphp-app

internally it calls
atomicapp -d install --update submod/guestbookphp-app
opt1 is for docker
opt2 is for atomicapp
opt3 is for sub commands of atomicapp..like install run uninstall
I underdstand this doesn't look pretty

@rhatdan
Copy link
Member

rhatdan commented Jul 2, 2015

You are substituting for the LABEL command, has nothing to do with docker, All we really are saying is substitute OPT1 with the contents of --opt1. We don't care where $OPT1 is with the LABEL. IE Whether it is early in the docker line or late.

LABEL RUN "docker ${OPT1} run ${IMAGE} ..."
LABEL RUN "docker run ${OPT1} ${IMAGE} ..."
LABEL RUN "docker run ${IMAGE} ${OPT1} ..."
Are all valid. If I don't have three substitutions in my LABEL, I would only use --opt1.

@sub-mod
Copy link
Contributor Author

sub-mod commented Jul 2, 2015

ahh ok makes sense
so is this OK ?
atomic install --opt1="-p :5000" --opt2="-d" --opt3="--update" submod/guestbookphp-app ?

@sub-mod
Copy link
Contributor Author

sub-mod commented Jul 2, 2015

With the way LABELs are written and used by atomic ,Suppose i want to expose a port in the atomic docker container and if it(-p option ) is not already mentioned in the LABELS , there no way other than using --opt1
So i was wondering should we FIX the location of OPT1 for docker only ?

@rhatdan
Copy link
Member

rhatdan commented Jul 2, 2015

No I don't think we should fix the location of --opt1/${OPT1} Leave it fully up the the image developer to specify how he wants the options to be used.

@rhatdan
Copy link
Member

rhatdan commented Jul 2, 2015

Remove "Sub"

...uninstall Sub Command.

Should be
...uninstall command.

@sub-mod
Copy link
Contributor Author

sub-mod commented Jul 2, 2015

ok done.

@rhatdan
Copy link
Member

rhatdan commented Jul 2, 2015

@sub-mod Sorry to be a pain, but lowercase Command and then I will merge.

Other then this, it LGTM

@sub-mod
Copy link
Contributor Author

sub-mod commented Jul 2, 2015

np

rhatdan added a commit that referenced this pull request Jul 2, 2015
Support OPT1, OPT2 in install/run command
@rhatdan rhatdan merged commit c97e5d3 into projectatomic:master Jul 2, 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.

6 participants