Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker build examples wrt shell #58

Closed
rcoup opened this issue Jul 20, 2018 · 2 comments
Closed

docker build examples wrt shell #58

rcoup opened this issue Jul 20, 2018 · 2 comments

Comments

@rcoup
Copy link

rcoup commented Jul 20, 2018

steps:
  - label: ':hammer: Build image'
    command: 
      - >
        docker build --pull
        --build-arg PIP_INDEX_URL=${PIP_INDEX_URL:-https://pip.example.net/root/dev/+simple/}
        --build-arg PIP_TRUSTED_HOST=${PIP_TRUSTED_HOST}
        -t acme/app:${BUILDKITE_BRANCH}.latest .
    plugins:
      docker#v1.4.0:
        image: "docker:stable"
        debug: true
        mounts:
          - /var/run/docker.sock:/var/run/docker.sock
Running docker build --pull --build-arg 
     PIP_INDEX_URL=${PIP_INDEX_URL:-https://pip.example.net/root/dev/+simple/}
     --build-arg PIP_TRUSTED_HOST=${PIP_TRUSTED_HOST} -t acme/app:citest.latest .
--|--
  | in docker:stable
  | $ docker run -it --rm --volume /buildkite/builds/abcdef123-1/acme/app:/workdir 
      --workdir /workdir --env BUILDKITE_JOB_ID --env BUILDKITE_BUILD_ID --volume
      /var/run/docker.sock:/var/run/docker.sock docker:stable bash -e -c docker build --pull 
      --build-arg PIP_INDEX_URL=${PIP_INDEX_URL:-https://pip.example.net/root/dev/+simple/} 
      --build-arg PIP_TRUSTED_HOST=${PIP_TRUSTED_HOST} -t acme/app:citest.latest .
  |  
  | /usr/local/bin/docker-entrypoint.sh: exec: line 35: bash: not found
  | 🚨 Error: The command exited with status 127

The docker images have busybox as sh, and no bash.

shell (optional)
Set the shell to use for the command. Set it to false to pass the command directly to the docker run command. The default is bash -e -c.

For my example setting shell: false works fine.

I wonder whether it should be sh -e -c to try and catch as many image variants as possible? The most common ${FOO:-default} etc stuff is all handled relatively consistently, even if some of the super-crazy bash'isms aren't. Or add a note to the docker build doc to say that if you need any complex stuff use shell: "sh -ec"?

@toolmantim
Copy link
Contributor

toolmantim commented Jul 21, 2018

Yep, we should make this change (originally mentioned it in #50 (comment) but never followed up). Probably worth a major version bump.

@lox
Copy link
Contributor

lox commented Oct 2, 2018

We've made some pretty major changes to how we handle shells in #68 which should cover this. The new default if a command is provided is [/bin/sh, -e, -c]

@lox lox closed this as completed Oct 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants