2017-07-24 52 views
0

我運行下面的命令來啓動哲基爾與我的本地簽出基於哲基爾網站:傳遞參數泊塢窗運行命令

docker run -p 4000:4000 --volume=$PWD:/srv/jekyll \ 
-it jekyll/jekyll:$JEKYLL_VERSION jekyll serve 

這一切正常。然而,當我通過它--baseurl說法是這樣的:

docker run -p 4000:4000 --volume=$PWD:/srv/jekyll \ 
-it jekyll/jekyll:$JEKYLL_VERSION jekyll serve --baseurl '' 

一切都正常運行一遍,直到它得到了這一點:

> docker run -p 4000:4000 --volume=$PWD:/srv/jekyll -it jekyll/jekyll:$JEKYLL_VERSION jekyll serve --baseurl '' 
Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.15.3). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`. 
The following gems are missing 
* jekyll (3.5.0) 
Install missing gems with `bundle install` 
Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.15.3). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`. 
Fetching gem metadata from https://rubygems.org/........... 
Fetching version metadata from https://rubygems.org/.. 
Fetching dependency metadata from https://rubygems.org/. 
Using public_suffix 2.0.5 
Using bundler 1.15.2 
Using colorator 1.1.0 
Using ffi 1.9.18 
Using forwardable-extended 2.6.0 
Using rb-fsevent 0.10.2 
Using kramdown 1.14.0 
Using liquid 4.0.0 
Using mercenary 0.3.6 
Using rouge 1.11.1 
Using safe_yaml 1.0.4 
Using jekyll-paginate 1.1.0 
Using addressable 2.5.1 
Using rb-inotify 0.9.10 
Using pathutil 0.14.0 
Using sass-listen 4.0.0 
Using listen 3.0.8 
Using sass 3.5.1 
Using jekyll-watch 1.5.0 
Using jekyll-sass-converter 1.5.0 
Fetching jekyll 3.5.0 
Installing jekyll 3.5.0 
Using jekyll-feed 0.9.2 
Bundle complete! 3 Gemfile dependencies, 22 gems now installed. 
Use `bundle info [gemname]` to see where a bundled gem is installed. 
The latest bundler is 1.15.3, but you are currently running 1.15.2. 
To update, run `gem install bundler` 
/usr/lib/ruby/gems/2.3.0/gems/mercenary-0.3.6/lib/mercenary/program.rb:31:in `go': missing argument: --baseurl (OptionParser::MissingArgument) 
    from /usr/lib/ruby/gems/2.3.0/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program' 
    from /usr/lib/ruby/gems/2.3.0/gems/jekyll-3.5.0/exe/jekyll:13:in `<top (required)>' 
    from /usr/bin/jekyll:22:in `load' 
    from /usr/bin/jekyll:22:in `<main>' 

這究竟是爲什麼?如何通過--basepath參數到jekyll命令?好像我在做一些與碼頭工人有關的問題,這是我的新手。

謝謝!

+0

嘗試用--baseurl '/' 或刪除它。 – marcanuy

回答

0

根據在https://docs.docker.com/v1.7/reference/run/#env-environment-variables的文檔,你可以在與-e參數泊塢窗運行命令傳遞。

這是我在一個簡單的運行腳本測試:

# Start Jekyll and watch for changes 
docker run --rm -it \ 
    -e JEKYLL_ENV=production \ 
    --volume=/$(pwd):/srv/jekyll \ 
    --publish 4000:4000 \ 
    $DOCKER_IMAGE_NAME 

圖像就是那麼grahamc /化身。我嘗試在上面的docker run命令中添加-e BASEURL =「」\。但是,我發現如果在_config.yml中設置了baseurl,則該設置會贏得環境設置。

+0

這需要在Dockerfile中定義該變量,不是嗎?我怎麼才能運行'--bashurl'''只是簡單的命令行? – user1902183