`bundle` not in Docker PATH - ruby

I have a docker image (which is delivered as-is, with no Dockerfile etc.) with Ruby application in it, when I try to run docker container with docker run application_image bundle exec puma -C config/puma.rb I get starting container process caused "exec: \"bundle\": executable file not found in $PATH": unknown.. All suggested fixes for this are to specidy stuff in Dockerfile (whick is not present there). Is there away to run container this way?

There are some walk-around maybe.
Create another docker image based on the existing one, with bundle installed
Install bundle before actually running the application

It's best if you can ask the image maintainer for instructions.
If that fails try exploring the docker image first like #hmm suggested see: https://stackoverflow.com/a/58256085/5641227 on how to do that.
Then either extract the image contents if your are allowed to and build it your self from scratch.
Or try building a new image from the one you have and add new build steps to the new Dockerfile:
FROM <your-current-image:and-tag>
RUN gem install bundler -v "~>2.0.2" --no-document --quiet --force
CMD ["bundle", "exec", "puma -C config/puma.rb"]
Then just run it after you tag and build your new image:
docker run new_application_image
Also, you need to have the right version of bundler. 2.0.2 is just an example. having a conflicting version won't work.

Related

failed to compute cache key: failed to create hash for <DIR>: operation not supported

while attempting to build an image in Docker/macOS, I get the following error:
failed to compute cache key: failed to create hash for
/app-temp/client/dist: operation not supported
My Dockerfile looks like this:
FROM node:lts-alpine as ui-build
WORKDIR /app-temp
COPY client/ ./client/
RUN cd client && npm install
RUN cd client && npm run build
FROM node:lts-alpine as api-build
WORKDIR /app
COPY --from=ui-build /app-temp/client/dist ./client/dist
COPY server/ ./server/
RUN cd server && npm install
EXPOSE 3000
CMD ["node", "/app/server/src/index.js"]
And the docker command that I am using is:
docker build -t test-image .
Now, note that the image is successfully built in a Linux machine. However, the above-mentioned error persists in a macOS machine.
I am running macOS Big Sur 11.2.1.
Any ideas as to how solve this problem?
Thanks in advance.
just in case someone else finds himself here
Look in your .dockerignore file if dist is in the list
Also, try building with BUILDKIT disabled
DOCKER_BUILDKIT=0 docker build ....
Im gonna throw my solution out there.
Setup: .net 5 web app with docker enabled, contains a dockerfile that was created by visual studio.
There was a step where the docker file was saying to copy my csproj up to the parent folder. I edited the source directory to from parent/myproject.csproj to myproject.csproj then I ran docker build and it worked.
Im assuming that when I run docker build I was down one level in the child folder where the dockerfile lives, and the paths just werent lining up.

How to run a fastlane lane in a docker image on Jenkins

I'm using Jenkins to run the CI. I'm using the docker image mingc/android-build-box to run a fastlane lane (dokka) in a container.
If I follow the guidelines suggested here and I run:
docker run --rm -v `pwd`:/project mingc/android-build-box bash -c 'cd /project; bundle exec fastlane dokka'
the operation succeeds but all the generated files are owned by root. This breaks the CI because I can't delete them when they are not necessary anynmore.
I tried to pass the CI user:
docker run --rm --user $(id -u):$(id -g) -v `pwd`:/project mingc/android-build-box bash -c "cd /project; bundle install --deployment; bundle exec fastlane dokka"
I get the error:
/ is not writable.
Bundler will use `/tmp/bundler20200511-6-m21qkb6' as your home directory temporarily.
bundler: failed to load command: fastlane (/usr/local/bin/fastlane)
Bundler::GemNotFound: Could not find aws-eventstream-1.1.0 in any of the sources
So I tried to call bundle install --deployment before bundle exec and now I get the error:
fileutils.rb:232:in `mkdir': [!] Permission denied # dir_s_mkdir - /.fastlane (Errno::EACCES)
I googled the error and I've found many reports but none of them contains a useful answer and anyway, this wouldn't be ideal because the docker image already has the fastlane gem installed and it would be good to be able to use it without having to reinstall it.
Another solution would be to let the container run with root as user and then delete the files after having used them. This solution is not ideal either because I would have to remember to delete every file created but the container.
If you're running this in Jenkins, its standard Docker support handles the mounts, permissions, etc. for you. In scripted pipeline code, it should be enough to do
docker.inside('mingc/android-build-box') {
sh 'bundle exec fastlane dokka'
}
Jenkins will mount the WORKDIR into the container (on an identical path), run as the same user ID, keep the same working directory, and so on. You can see in its logs the (rather long) docker run command it uses.

docker-compose command not available for mac

I installed docker with the instructions here, downloading from docker-hub
https://docs.docker.com/docker-for-mac/install/
But when I run docker-compose I get this error
pyenv: docker-compose: command not found
The `docker-compose' command exists in these Python versions:
3.6.5/envs/myenv
Also, docker-compose is available under /Users
which docker-compose
/Users/<username>/.pyenv/shims/docker-compose
In this link says, docker-compose for mac need not be installed explicitly as it is part of docker for desktop mac.
https://docs.docker.com/compose/install/
Is something wrong with my installation?
I ran into the same issue on macOS today. Turned out that you need to run the installed app once, it does some additional downloading and setup. That setup includes setting up your path variables.
docker-compose is a utility that is now a parameter in mac docker
so instead of docker-compose up, its now docker compose up
if you install docker from official website then docker-compose will come along with that for mac so need to either upgrade and documentation is present there.

Docker unable to process Dockerfile

I trying to create Dockerfile file from scratch on Windows7. However, currently have trouble on very first step. My Dockerfile is placed under C:\Users\Arturas\Docker\Jenkins. Virtual Box shared folder path on c:\Users and folder name on c/Users (defaults from boot2docker was not changed).
When I run (on git bash):
$ docker build --file Docker/Jenkins/ .
I get:
unable to process Dockerfile: read C:\Users\Arturas\Docker\Jenkins:
The handle is invalid.
Dockerfile content is just one line:
FROM jenkins
I just started learning Docker so my experience is very limited yet. However from tools like boot2docker I expect basic commands to work out of the box so I must be missing something.
Try instead:
cd /C/Users/Arturas/Docker/Jenkins
docker build -t myimage .
I assume here that you have a file named Dockerfile under the Jenkins folder.
The -f option of a docker build is for referencing the Dockerfile (if it is named differently for instance)
Don't forget to use the latest docker-machine (the 0.5.4 one: an auto-extractible exe docker-machine_windows-amd64.exe): it uses a VM named boot2docker.iso through VirtualBox.
Try to specify the "Dockerfile" name
$ docker build --file Docker/Jenkins/Dockerfile .

ADD Command for Docker Toolbox on Mac

I have Docker Toolbox installed on my Mac, but I'm having issues adding a file to a container during build. I'm using the ADD command in the Dockerfile. I can't seem to add any local files. I understand that Docker Toolbox uses VirtualBox under the hood, but I am not sure how to get those files into the VM to build the container. Is there a way I can do it that allows me to keep a clean OS-agnostic Dockerfile without any absolute paths?
Here is my Dockerfile. It's built from the Node.js container with some additional dependencies.
FROM node:4.2.2
RUN apt-get update
RUN apt-get install -y libvips-dev libgsf-1-dev libkrb5-dev
RUN apt-get clean
ADD app/ /app
RUN cd /app && npm install --production
RUN npm install forever -g
Turns out this does work, but only for my current directory. My Dockerfile and the files I wanted to add were not in the same directory. Moving the shell to the files I wanted, and then manually specifying the Dockerfile worked.
docker build -f my/other/Dockerfile .
Since docker will use a VirtualBox VM on Mac (with boot2docker or with docker-machine), it will use VirtualBox Guest Additions, which is there for the express purpose of using VirtualBox folder sharing.
Make sure to be in such a shared path, typically in /Users/....
If app/ is in /Users/path/to/app, then ADD should work.
You can mount other paths with boot2docker, but it can be problematic with docker machine (see issue 13).
Of course, for ADD app ... to work, you need to be in the parent folder of app/.
From docker ADD:
The <src> path must be inside the context of the build; you cannot ADD ../something /something

Resources