envygeeks / jekyll-docker

⛴ Docker images, and CI builders for Jekyll.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot run 'bundle install' inside docker container

rzuckerm opened this issue · comments

I'm running this:

export JEKYLL_VERSION=latest
docker run --rm \
    -e "JEKYLL_UID=$(id -u)" \
    -e "JEKYLL_GID=$(id -g)" \
    -v "$PWD/docs:/srv/jekyll:Z" \
    -w "/srv/jekyll" \
    -it jekyll/jekyll:$JEKYLL_VERSION \
    bash -c "bundle install && jekyll build -V --config _config.yml"

and I'm seeing this error for bundle install:

Could not reach host index.rubygems.org. Check your network connection and try again.

I can ping this host outside the docker container:

$ ping index.rubygems.org
PING rubygems.org (151.101.65.227) 56(84) bytes of data.
64 bytes from 151.101.65.227 (151.101.65.227): icmp_seq=1 ttl=56 time=26.9 ms
64 bytes from 151.101.65.227 (151.101.65.227): icmp_seq=2 ttl=56 time=23.1 ms
...

But I cannot ping this host inside the docker container:

bash-5.1# ping index.rubygems.org
ping: bad address 'index.rubygems.org'

If I add index.rubygems.org as 151.101.65.227 to /etc/hosts and re-run bundle install, I see errors like this:

Retrying download gem from https://rubygems.org/ due to error (2/4): Gem::RemoteFetcher::FetchError SocketError: Failed to open TCP connection to rubygems.org:443 (getaddrinfo: Try again) (https://rubygems.org/gems/concurrent-ruby-1.2.2.gem)

If I downgrade to JEKYLL_VERSION=3.8.0, I see this issue:

Fetching source index from https://rubygems.org/

Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org/

Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org/

Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org/

Could not fetch specs from https://rubygems.org/

Here is my Gemfile:

source "https://rubygems.org"

# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
gem "github-pages", group: :jekyll_plugins

# For testing purposes
gem "html-proofer"

# If you have any plugins, put them here!
group :jekyll_plugins do
  gem "jekyll-feed", "~> 0.6"
  gem 'jekyll-sitemap'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]

# Performance-booster for watching directories on Windows
gem "wdm", "~> 0.1.0" if Gem.win_platform?

About the only way I could get this to work was to add the following items to the docker run:

--add-host "rubygems.org:151.101.193.227" --add-host "index.rubygems.org:151.101.193.227"

Not sure why I have to do that.

NVM, I found a problem with my networking on Ubuntu 22.04 VM.