将参数传递给docker run命令
我正在运行以下命令启动Jekyll与我的本地签出Jekyll网站:
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
参数传递给--basepath
命令? 似乎我正在做一些与码头工人有关的问题,这是我所熟悉的。
谢谢!
根据https://docs.docker.com/v1.7/reference/run/#env-environment-variables上的文档,您可以用docker run命令和-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
图片简单地是格雷厄姆/ jekyll。 我尝试在上面的docker run命令中添加-e BASEURL =“”\。 但是,我发现如果在_config.yml中设置了baseurl,那么设置就会胜过环境设置。