dnsmasq在docker中无应答

为jekyll制作docker镜像

妙音 posted @ 2019年4月28日 10:08 in docker with tags jekyll docker , 1501 阅读

说明

 
jekyll运行依赖ruby,每次重装都会遇到版本问题,挺麻烦,干脆做成镜像
 
 

官方镜像存在的问题

 
docker上有jekyll的官方镜像,如果是直接运行,没什么问题。
 
如果你挂载volume就会有权限问题
 
jekyll 3.8.5 | Error:  Permission denied @ dir_s_mkdir - /srv/jekyll/_site
 
 

制作步骤

 
步骤1:修改镜像入口文件entrypoint
 
从官方镜像jekyll中拿到入口文件,做一点修改
 
 
#!/bin/bash
[ "$DEBUG" = "true" ] && set -x
set -e

# --
: ${JEKYLL_UID:=$(id -u jekyll)}
: ${JEKYLL_GID:=$(id -g jekyll)}

# --
export JEKYLL_UID
export JEKYLL_GID

# --
# Users can customize our UID's to fit their own so that
#   we don't have to chown constantly.  Well it's not like
#   we do so much of it (anymore) it's slow, but we do
#   change permissions which can result in some bad
#   behavior on OS X.
# --
if [ "1" != "0" ] ; then     # 修改了此处,改目录权限
  usermod  -u $JEKYLL_UID jekyll
  groupmod -g $JEKYLL_GID jekyll
  chown_args=""

  [ "$FULL_CHOWN" ] && chown_args="-R"
  for d in "$JEKYLL_DATA_DIR" "$JEKYLL_VAR_DIR"; do
    chown $chown_args jekyll:jekyll "$d"
  done
fi

# --
exec "$@"
 
 
步骤2:镜像制作脚本,dockerfile文件
 
FROM jekyll/builder:3.8

COPY --chown=jekyll:jekyll entrypoint  /usr/jekyll/bin/entrypoint

RUN gem install jekyll-admin  redcarpet
 
 
步骤3:编译镜像
 
docker build . -t wyq/blog:0.1
 
步骤4:启动脚本,docker-compose.yml文件
 
version: '2'
services:
  blog:
    image: wyq/blog:0.1
    volumes:
            - ./blog:/srv/jekyll
    ports:
      - "4000:4000"
    command: jekyll serve -P 4000 -H 0.0.0.0 -w
 
步骤5:启动
 
docker-compose -f docker-compose.yml up
 
来源
 
 

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter