docker-compose fails on RUN sudo gem update --system - windows

Installed docker desktop for windows in a Hyper-V VM running Windows 10 21H2. Have cloned a repository from GitHub using the GitHub desktop. Started a PowerShell as administrator, navigated to the cloned repository location. When I run docker-compose up I get the following error:
[+] Building 3.7s (5/9)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 32B 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/circleci/ruby:2.7.5-node 3.3s
=> CACHED [1/6] FROM docker.io/circleci/ruby:2.7.5-node#sha256:23d760208eed58ff57f8721d20dcd8c9bc5f9ee8a5293fa14 0.0s
=> ERROR [2/6] RUN sudo gem update --system 0.2s
[2/6] RUN sudo gem update --system:
#0 0.197 sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges?
failed to solve: executor failed running [/bin/sh -c sudo gem update --system]: exit code: 1
docker itself installed ok and is running. I've checked all the pre-reqs and can see no reason why this is happening. Has anyone else experienced this?

Related

Laravel install via Docker on WSL2 never stops building

I'm trying to install a fresh Laravel 9 on Windows 10/WSL 2 with Docker. I followed the documentation and once I run the first command it gets stuck during building when it gets to the 4/11 stage, running endlessly until I have to cancel.
Here is what it looks like in the Terminal:
=> [ 4/11] RUN apt-get update && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervis 167.8s
=> => # Processing triggers for ca-certificates (20211016ubuntu0.22.04.1) ...
=> => # Updating certificates in /etc/ssl/certs...
=> => # 0 added, 0 removed; done.
=> => # Running hooks in /etc/ca-certificates/update.d...
=> => # done.
=> => # gpg: keybox '/root/.gnupg/pubring.kbx' created
I used Unbuntu and Docker is fresh install. I don't understand what seems to be the problem here.
Honestly I didn't try much, I have no idea what the issue is...

install laravel9.1 by sail docker-compose cant build

After using sail build --no-cache command, apt-key is stuck。
mysql uses an image, skipping
redis uses an image, skipping
meilisearch uses an image, skipping
mailhog uses an image, skipping
selenium uses an image, skipping
Building laravel.test
[+] Building 3654.7s (7/15)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 2.39kB 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/ubuntu:21.10 0.7s
=> [ 1/11] FROM docker.io/library/ubuntu:21.10#sha256:cc8f713078bfddfe9ace41e29eb73298f52b2c958ccacd1b376b9378e20906ef 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 99B 0.0s
=> CACHED [ 2/11] WORKDIR /var/www/html 0.0s
=> [ 3/11] RUN ln -snf /usr/share/zoneinfo/UTC /etc/localtime && echo UTC > /etc/timezone 0.2s
=> [ 4/11] RUN apt-get update && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 && mkdir -p ~/.gnupg && chmod 600 ~/.gnupg 3653.7s
=> => # Updating certificates in /etc/ssl/certs...
=> => # 0 added, 0 removed; done.
=> => # Running hooks in /etc/ca-certificates/update.d...
=> => # done.
=> => # Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
=> => # Executing: /tmp/apt-key-gpghome.itanfA6ojm/gpg.1.sh --homedir /root/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E5267A6C
please help me,how to solve this problem. thank you very much.

installing fbprophet in docker file docker build on M1 Mac does not work

Does anyone know how to install fbprophet in the docker file for the Mac M1 pro ? As I am unable to install it citing
below is instructions saved in a text file named "dockerfile":
FROM jupyter/scipy-notebook:python-3.9.7
RUN pip install fbprophet
ENV PYTHONPATH "${PYTHONPATH}:/home/jovyan/work"
RUN echo "export PYTHONPATH=/home/jovyan/work" >> ~/.bashrc
WORKDIR /home/jovyan/work
Followed by entering the command line "docker build -t fbprophet-notebook:latest ."
the information shows:
Successfully built pymeeus
#6 18.13 Failed to build fbprophet pystan
#6 18.57 Installing collected packages: setuptools-git, pymeeus, korean-lunar-calendar, ephem, pystan, hijri-converter, convertdate, LunarCalendar, holidays, cmdstanpy, fbprophet
#6 18.97 Running setup.py install for pystan: started
#6 22.85 Running setup.py install for pystan: finished with status 'error'
I tried enter this command line:
docker run -dit --rm --name adv_dsi_lab_2 -p 8888:8888 -e JUPYTER_ENABLE_LAB=yes -v "$PWD":/home/jovyan/work fbprophet-notebook:latest .
The result was:
(base) user#user-MacBook-Pro adv_dsi_lab_2 % docker run -dit --rm --name adv_dsi_lab_2 -p 8888:8888 -e JUPYTER_ENABLE_LAB=yes -v "$PWD":/home/jovyan/work fbprophet-notebook:latest .
Unable to find image 'fbprophet-notebook:latest' locally
docker: Error response from daemon: pull access denied for fbprophet-notebook, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.
Where did I go wrong?

Bundler locks in docker + can't install gems (Solved- docker CMD vs ENTRYPOINT)

Update: I've narrowed the [or a?] problem down to the line - groupy-gemcache:/usr/local/bundle in my services: app: volumes dictionary. If I remove it, the container runs fine [i think] but presumably i lose my local gem cacheing.
tldr: After running docker-compose build, things seem ok, but I cannot run any gem or bundle inside my running docker container if I add something to my gemfile. for example, after docker-compose build && docker-compose run app bash:
root#2ea58aff612e:/src# bundle check
The Gemfile's dependencies are satisfied
root#2ea58aff612e:/src# echo 'gem "hello-world"' >> Gemfile
root#2ea58aff612e:/src# bundle
Could not find gem 'hello-world' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.
root#2ea58aff612e:/src# bundle install
Could not find gem 'hello-world' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.
root#2ea58aff612e:/src# gem
Could not find gem 'hello-world' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.
root#2ea58aff612e:/src# gem env
Could not find gem 'hello-world' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.
I'm still pretty novice with docker, but i've been trying to configure a perfect dockerfile that can build, cache gems and update while still committing its Gemfile.lock to git [maybe this isn't actually perfect and I'm open to suggestions there]. In my use case, I'm using a docker compose file with images for a rails app and sidekiq worker as well as postgres and redis images- very simliar to the setups described here and here.
My Dockerfile [some things commented out that I cobbled from the tutorials above:
FROM ruby:2.3
ENTRYPOINT ["bundle", "exec"]
ARG bundle_path
# throw errors if Gemfile has been modified since Gemfile.lock
# RUN bundle config --global frozen 1
ENV INSTALL_PATH /src
RUN mkdir -p $INSTALL_PATH
WORKDIR $INSTALL_PATH
# Install dependencies:
# - build-essential: To ensure certain gems can be compiled
# - nodejs: Compile assets
# - npm: Install node modules
# - libpq-dev: Communicate with postgres through the postgres gem
# - postgresql-client-9.4: In case you want to talk directly to postgres
RUN apt-get update && apt-get install -qq -y build-essential nodejs npm libpq-dev postgresql-client-9.4 --fix-missing --no-install-recommends && \
rm -rf /var/lib/apt/lists/*
COPY app/Gemfile app/Gemfile.lock ./
# Bundle and then save the updated Gemfile.lock in our volume since it will be clobbered in the next step
RUN echo $bundle_path && bundle install --path=$bundle_path && \
cp Gemfile.lock $bundle_path
# ./app contains the rails app on host
COPY app .
# Unclobber the updated gemfile.lock
RUN mv $bundle_path/Gemfile.lock ./
CMD ["./script/start.sh"]
docker-compose.yml:
version: '2'
volumes:
groupy-redis:
groupy-postgres:
groupy-gemcache:
services:
app:
build:
args:
bundle_path: /usr/local/bundle
context: .
dockerfile: Dockerfile
command: "./script/start.sh"
links:
- postgres
- redis
volumes:
- ./app:/src
- groupy-gemcache:/usr/local/bundle
ports:
- '3000:3000'
env_file:
- .docker.env
stdin_open: true
tty: true
Wow, I figured it out. The problem was coming from my ENTRYPOINT dockerfile command, as explained at the end of this article on CMD vs ENTRYPOINT.
I believe the result of ENTRYPOINT ["bundle", "exec"] with CMD ["./script/start.sh"] OR docker-compose run app bash was to run a command like bundle exec 'bash'. I confirmed this by removing the entrypoint from the dockerfile, entering the shell as above and manually running bundle exec 'bash' and sure enough i landed in a subshell where I couldn't run any bundle or gem commands- had to exit twice to leave.

Getting Errno::ENOENT: No such file or directory - createdb in a padrino api when creating a database in docker

I am pretty new in padrino so I have been struggling with this for a while and it is really blocking me.
What I am trying to do is, to dokerize my padrino project in order to make it available to my front end co-workers so they don't need to spend to much time setting their machines up.
The problem comes when I try to run the docker-compose run web bundle exec rake sq:create task which raises the the following exception:
=> Creating database 'my_database_dev'
rake aborted!
Errno::ENOENT: No such file or directory - createdb
/usr/local/bundle/gems/padrino-gen-0.13.2/lib/padrino-gen/padrino-tasks/sql-helpers.rb:18:in `spawn'
/usr/local/bundle/gems/padrino-gen-0.13.2/lib/padrino-gen/padrino-tasks/sql-helpers.rb:18:in `create_db'
/usr/local/bundle/gems/padrino-gen-0.13.2/lib/padrino-gen/padrino-tasks/sequel.rb:52:in `block (2 levels) in <top (required)>'
/usr/local/bundle/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
/usr/local/bin/bundle:22:in `load'
/usr/local/bin/bundle:22:
That exception only happens on my docker machine, even using DATABASE_URL=postgres://pg_pass:pg_user#postgres.local:2345/my_database_dev which correspond to the dockerized postgres image in my local .env file everything runs as expected, so that makes me think that the issue is that something is missing in Dockerfile.
My Dockerfile looks like this:
FROM ruby:2.2.5
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev
RUN mkdir /app
WORKDIR /app
ADD Gemfile /app/Gemfile
ADD Gemfile.lock /app/Gemfile.lock
RUN bundle install
ADD . /app
and my docker-compose file
version: '2'
services:
db:
image: postgres:latest
ports:
- "2345:5432"
environment:
- POSTGRES_PASSWORD=pg_pass
- POSTGRES_USER=pg_user
web:
build: .
command: bundle exec padrino s -p 3000 -h '0.0.0.0'
ports:
- "3000:3000"
volumes:
- .:/app
depends_on:
- db
links:
- db:db
environment:
- DATABASE_URL=postgres://pg_pass:pg_user#postgres.local:2345/my_database_dev
Thank you in advance!
I encountered the very same problem just a couple of hours ago. This error, Errno::ENOENT: No such file or directory - createdb, indicates that your web container can't locate createdb, a script provided by Postgres. To solve this, add postgresql-client to your Dockerfile
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev postgresql-client
re-build your web container
docker-compose build web
and re-run the db creation & migration
docker-compose run web bundle exec rake sq:create
docker-compose run web bundle exec rake sq:migrate

Resources