Shippable / support

Shippable SaaS customers can report issues and feature requests in this repository
101 stars 28 forks source link

How can I execute docker run -t -v in shippable? #5168

Closed bate-ye-edo closed 3 years ago

bate-ye-edo commented 3 years ago

Description of your issue:

Hello, I'm trying to run this command in my shippable.yml file: docker run -t -v pwd:/test wolfye98/proyecto_iv_bate I want to use a Docker image that I created, but it always appear this error: no gulp file founded. Here is my Dockerfile:

FROM node:14.14.0-alpine LABEL version="1.0.8" maintainer="mingye@hotmail.es" RUN addgroup -S bateyeg && adduser -S bateye -G bateyeg COPY package.json ./ RUN npm install RUN rm package.json RUN npm install -g gulp USER bateye VOLUME /test WORKDIR /test CMD ["gulp","test"]

And my shippable.yml is: language: node_js services:

This image and the command docker run... works on my local and on Travis but in shippable it doesn't work, can someone help me?

a-murphy commented 3 years ago

The pre_ci_boot section specifies an image to use to run the step, so you're actually running your docker run command in another copy of your image. If that's what you intended, that's fine. It's just a little unusual.

Since the docker run command runs with Docker on the host, it starts a new container alongside the build container, and the volume mount is from the host. Adding a volume mount from the host to the build container by adding options: "-v $SHIPPABLE_BUILD_DIR:$SHIPPABLE_BUILD_DIR" to your pre_ci_boot section should work as you have it set up. However, I would consider running gulp test in the ci section instead of docker run because the log output tends to be easier to read.

bate-ye-edo commented 3 years ago

Hi! Thank you for responding this. Gulp test works perfectly, but I want to try to execute the docker image because it is a requirement of a University Practice. I have added the line options: "-v $SHIPPABLE_BUILD_DIR:$SHIPPABLE_BUILD_DIR" but now it has some new fails:

wait for exit:
    - echo Container c.exec.Proyecto_IV_Bate.43.1 exited with 1
           Container c.exec.Proyecto_IV_Bate.43.1 exited with 1
   - sudo docker logs c.exec.Proyecto_IV_Bate.43.1
           standard_init_linux.go:190: exec user process caused "no such file or directory"
   - sudo docker rm -fv $CONTAINER_NAME
           c.exec.Proyecto_IV_Bate.43.1
a-murphy commented 3 years ago

Does your image meet the minimum requirements for use as a build image? One possible reason may be if it is trying to run a Bash script without Bash.

Is there a reason you need to use your image both to run the docker run command and for another container that runs the gulp command? Could you use one of the Shippable images in pre_ci_boot (directions to just add the volume mount and use the default image are here) since you are only using that container to run the docker run command?

bate-ye-edo commented 3 years ago

I need to use my container just because the exercise ask me that, and I have been trying a lot in Shippable but I can't find any solution for that. I think that my image has apt-get, and it built on UBUNTU20.04, can that be a problem? And I just deleted the pre_ci_boot section and the execution of:

docker run -t -v `pwd`:/test wolfye98/proyecto_iv_bate

still says: no gulpfile found

It doesn't work neither with:

docker run -t -v $SHIPPABLE_BUILD_DIR:/test wolfye98/proyecto_iv_bate

But I check that my gulpfile is inside the $SHIPPABLE_BUILD_DIR, with:

cat $SHIPPABLE_BUILD_DIR/gulpfile.js
a-murphy commented 3 years ago

It's the volume mount between the build container in pre_ci_boot and the host that will make the volume mount to your container work. A pre_ci section would also clone to the host, but won't help the build image to run.

So you have to only run commands in your image? Or could you start your container with docker run on the host? I'm not sure what your limitations are, but it looks like your image has an Alpine base image, and those are often missing requirements.

Without a pre_ci_boot section, it will use the default build image for the language to run the ci section, which is how it is able to get to the docker run command. Adding a pre_ci section might be an option to clone the repository to the host for the volume mount to work in your docker run, but any commands in the ci section still run in the "build container," which has to meet the minimum requirements.

bate-ye-edo commented 3 years ago

Mm okey, I think I will write to my professor to ask him if I can just use gulp test cause the problem may be my docker image. Thank you very much!