Answers: <p>If you have docker compose installed on the Jenkins Build machine you can use <code>sh docker-compose up</code> to run docker-compose from a new shell.</p>
  
  <p>In general, you can run any command from your JenkinsFile using the <code>sh</code> command.</p>
  
Answers: CC BY-SA 3.0
Answers: 2018-02-27T05:45:25.723Z
Answers: See here for possible hangups and workarounds.  https://reinout.vanrees.org/weblog/2017/10/03/docker-compose-in-jenkins.html
Answers: avi
Answers: CC BY-SA 3.0
Answers: 2018-02-27T18:16:59.750Z
Answers: I am running on coreos, which doesn't support working as a jenkins slave (to my knowledge), without doing a bunch of manual steps. I thought that was the purpose of using the docker api so you didn't need to connect to a jenkins slave in the traditional way and could just rely on the remote api?
Answers: scott
Answers: CC BY-SA 3.0
Answers: 2018-02-28T12:20:03.833Z
Answers: @scott I think you still need the slave so it can report the status etc. The benefit of docker is your environment is clean and the same from the build to the deployment.
Answers: avi
Answers: CC BY-SA 3.0
Answers: 2018-02-27T05:42:58.670Z
Answers: 2018-02-27T05:42:58.670Z
Answers: avi
Body: <p>When I do <code>docker run</code> I have to give extensive argument options for my container setup.  To mitigate this and ensure all developers are using the same arguments I switched to docker-compose.  </p>
  
  <p>Now when I try to go run the same build from jenkins I can no longer use the docker plugin since no jenkins plugins seem to support <code>docker-compose up</code>, they all need to use the <code>docker</code> commands for the remote API instead of the <code>docker-compose</code> commands.</p>
  
  <p>Unless there are reasons not to, I would prefer <code>docker-compose up</code>.  I am aware I could create a bash script the does <code>docker run &lt;arguments&gt;</code> and let my jenkinsfile parse the script and load in the proper args but this feels ultra hacky.</p>
  
  <p>How can I use one or the other and keep them both in SCM and ensure that if a change is made to docker source (either the <code>docker-compose.yml</code> or possible a bash script running <code>docker run</code> with the proper arguments), it will work in both places?  Are there tools for this?  a plugin I am missing?</p>
  
  <p>Also I desire to use CoreOs which doesn't natively support jenkins (no java and other things).</p>
  
Tags: <docker><jenkins><jenkins-plugins><jenkins-pipeline><docker-compose>
Title: How to integrate docker-compose or docker run command arguments into SCM and Jenkins build?
UserDisplayName: scott
ThreadText: # How to integrate docker-compose or docker run command arguments into SCM and Jenkins build?
  
  (Asked by: username_0 on 2018-02-26)
  
  When I do `docker run` I have to give extensive argument options for my container setup. To mitigate this and ensure all developers are using the same arguments I switched to docker-compose.
  
  Now when I try to go run the same build from jenkins I can no longer use the docker plugin since no jenkins plugins seem to support `docker-compose up`, they all need to use the `docker` commands for the remote API instead of the `docker-compose` commands.
  
  Unless there are reasons not to, I would prefer `docker-compose up`. I am aware I could create a bash script the does `docker run <arguments>` and let my jenkinsfile parse the script and load in the proper args but this feels ultra hacky.
  
  How can I use one or the other and keep them both in SCM and ensure that if a change is made to docker source (either the `docker-compose.yml` or possible a bash script running `docker run` with the proper arguments), it will work in both places? Are there tools for this? a plugin I am missing?
  
  Also I desire to use CoreOs which doesn't natively support jenkins (no java and other things).
  
  **Tags:** docker, jenkins, jenkins-plugins, jenkins-pipeline, docker-compose
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-02-27. Score: 0 | Accepted answer
  
  If you have docker compose installed on the Jenkins Build machine you can use `sh docker-compose up` to run docker-compose from a new shell.
  
  In general, you can run any command from your JenkinsFile using the `sh` command.
  
  > **Comments:**
  > **username_1**: See here for possible hangups and workarounds.  https://reinout.vanrees.org/weblog/2017/10/03/docker-compose-in-jenkins.html  
  > **username_0**: I am running on coreos, which doesn't support working as a jenkins slave (to my knowledge), without doing a bunch of manual steps. I thought that was the purpose of using the docker api so you didn't need to connect to a jenkins slave in the traditional way and could just rely on the remote api?  
  > **username_1**: @username_0 I think you still need the slave so it can report the status etc. The benefit of docker is your environment is clean and the same from the build to the deployment.  
  
  ---
  
  