传递参数泊坞窗运行命令

问题描述:

我运行下面的命令来启动哲基尔与我的本地签出基于哲基尔网站:传递参数泊坞窗运行命令

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

根据在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