Docker V2, cant seem execute command passed in from steps in YAML


I have defind my steps and am using the v2 version and do have a docker file, but it seems that everytime the container runs it fails to execute the command passed in through the yaml decleration.

my intent is to have a build pipeline with the following steps:

  1. simple prebuild scripts.

  2. container is run using docker file which installs all necessary dependencies, i believe these steps are cached so there wont be a performance hit, using the installed dependencies, I will try to navigate to the appropriate folder using an env var and build the .net solution. docker file then copies all files into an artifact folder using copy command.(i am not sure how this would behave on multiple container runs, if better way possible then please do suggest)

  3. the same container is run in this step, dependencies are installed, I will then try to access the artifacts folder created in the previous step, navigate to the tests folder using an env variable and run the tests.

  4. if the above step has succeeded I will run the container again, install dependencies that allow for deployment to AWS and try to access the artifacts folder and publish the built solution to aws.

(if there is a way to include env variables in a seprate file that would be great, please do let me know)

docker file:

FROM ubuntu:16.04

RUN apt-get update
RUN apt-get install -y apt-utils wget
RUN wget -q
RUN dpkg -i packages-microsoft-prod.deb
RUN apt-get install -y apt-transport-https
RUN apt-get update
RUN apt-get install -y dotnet-sdk-2.1

COPY ./ /artifacts
ENTRYPOINT [ "sh", "-c",] #tried withouth this line too

steps file:


  - label: 'pre-build'
    command: 'scripts/pipeline/'
  - wait
  - label: 'build'
    command: 'artifacts/scripts/pipeline/' #cant find or execute this
       BUILDKITE_DOCKER: true 
  - wait
  - label: 'unit test'
    command: 'artifacts/scripts/pipeline/' # cant find or execute this

with entry point:

Step 11/11 : ENTRYPOINT [ "sh", "-c"]
---> Running in c73b419af9aa
Removing intermediate container c73b419af9aa
---> 90360e657e99
Successfully built 90360e657e99
Successfully tagged buildkite_f0ece180-0523-44bc-966d-045fd6b28bb4_image:latest
Running build script (in Docker container) 0s
$ docker run --name buildkite_f0ece180-0523-44bc-966d-045fd6b28bb4_container buildkite_f0ece180-0523-44bc-966d-045fd6b28bb4_image ./buildkite-script-f0ece180-0523-44bc-966d-045fd6b28bb4
sh: 1: ./buildkite-script-f0ece180-0523-44bc-966d-045fd6b28bb4: not found

without entry point:

Step 9/10 : RUN apt-get install -y dotnet-sdk-2.1
    ---> Using cache
    ---> 39715f94eb6a
    Step 10/10 : COPY ./ /artifacts
    ---> 57a070f57f3f
    Successfully built 57a070f57f3f
    Successfully tagged buildkite_f40f919c-76da-4edf-b22d-d7f5befc891b_image:latest
    Running build script (in Docker container) 0s
    $ docker run --name buildkite_f40f919c-76da-4edf-b22d-d7f5befc891b_container buildkite_f40f919c-76da-4edf-b22d-d7f5befc891b_image ./buildkite-script-f40f919c-76da-4edf-b22d-d7f5befc891b
    docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"./buildkite-script-f40f919c-76da-4edf-b22d-d7f5befc891b\": stat ./buildkite-script-f40f919c-76da-4edf-b22d-d7f5befc891b: no such file or directory": unknown.

link to public repo:

if i was to change the entrypoint to this:

COPY ./ /artifacts
ENTRYPOINT [ "sh", "-c", "bash"]

then I would not get an error but still it seems like nothing is happening and the scripts are not being executed:

Running command (in Docker container) 0s
$ docker run --name buildkite_03f62504-c1dc-4522-a87d-a365a4bf9716_container buildkite_03f62504-c1dc-4522-a87d-a365a4bf9716_image ./scripts/pipeline/
Cleaning up Docker containers 0s
$ docker rm -f -v buildkite_03f62504-c1dc-4522-a87d-a365a4bf9716_container

When building and running dockerfile locally it seems to be able to find the script and run them:

farha@DESKTOP-J9B5HJG MINGW64 ~/OneDrive/Desktop/Test-master
$ docker build --tag=test .
Sending build context to Docker daemon  23.55kB
Step 1/11 : FROM ubuntu:16.04
 ---> 9361ce633ff1
Step 2/11 : MAINTAINER Farhad Taran ""
 ---> Using cache
 ---> 0e0a7e5d5b05
Step 3/11 : RUN apt-get update
 ---> Using cache
 ---> 006ac4d142f8
Step 4/11 : RUN apt-get install -y apt-utils wget
 ---> Using cache
 ---> 8edcad02ead5
Step 5/11 : RUN wget -q
 ---> Using cache
 ---> 3675a9fca579
Step 6/11 : RUN dpkg -i packages-microsoft-prod.deb
 ---> Using cache
 ---> 85b221a6efb4
Step 7/11 : RUN apt-get install -y apt-transport-https
 ---> Using cache
 ---> af9061a7827c
Step 8/11 : RUN apt-get update
 ---> Using cache
 ---> 88491412c738
Step 9/11 : RUN apt-get install -y dotnet-sdk-2.1
 ---> Using cache
 ---> 48560dde6dc0
Step 10/11 : COPY ./ /artifacts
 ---> 333b32534285
Step 11/11 : ENTRYPOINT [ "sh", "-c", "artifacts/scripts/pipeline/"]
 ---> Running in c86a63e606f8
Removing intermediate container c86a63e606f8
 ---> b795e1b250ea
Successfully built b795e1b250ea
Successfully tagged test:latest
SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.

farha@DESKTOP-J9B5HJG MINGW64 ~/OneDrive/Desktop/Test-master
$ docker run test
running build!

Welcome to .NET Core!
Learn more about .NET Core:
Use 'dotnet --help' to see available commands or visit:

The .NET Core tools collect usage data in order to help us improve your experience. The data is anonymous and doesn't include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET Core CLI Tools telemetry:

Successfully installed the ASP.NET Core HTTPS Development Certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only). For establishing trust on other platforms refer to the platform specific documentation.
For more information on configuring HTTPS see
MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.


Hi @ftaran!

Sorry you’re having trouble getting that setup to work with Buildkite Agent v2. The v2 Docker support has long been deprecated, and I’ve had trouble reproducing it locally :pensive:

Have you tried writing plan bash scripts in your repository, that manually perform the Docker commands you need?

One other thing is that buildkite steps are meant to be stateless, so I’m worried that your steps could run on different agents so the pre-build and build are run somewhere, and then the unit-test is run somewhere else. Perhaps all the commands should be run in a single shell-script?