为jekyll制作docker镜像
2019年4月28日 10:08
说明
jekyll运行依赖ruby,每次重装都会遇到版本问题,挺麻烦,干脆做成镜像
官方镜像存在的问题
docker上有jekyll的官方镜像,如果是直接运行,没什么问题。
如果你挂载volume就会有权限问题
1 | jekyll 3.8.5 | Error: Permission denied @ dir_s_mkdir - /srv/jekyll/_site |
1 | jekyll 3.8.5 | Error: Permission denied @ dir_s_mkdir - /srv/jekyll/_site |
1 2 3 4 5 | dig www.google.com @192.168.0.111 -p 53 ; <<>> DiG 9.11.3-RedHat-9.11.3-4.fc27 <<>> www.google.com @192.168.0.111 -p 53 ;; global options: +cmd ;; connection timed out; no servers could be reached |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | [root@bogon ss] # docker-compose -f chinadns.yml up dns-dnsmasq Starting ss_dns-dnsmasq_1 ... done Attaching to ss_dns-dnsmasq_1 dns-dnsmasq_1 | dnsmasq: started, version 2.79 cachesize 150 dns-dnsmasq_1 | dnsmasq: compile time options: IPv6 GNU-getopt no-DBus no-i18n no-IDN DHCP DHCPv6 no-Lua TFTP no-conntrack ipset auth no-DNSSEC loop-detect inotify dns-dnsmasq_1 | dnsmasq: using nameserver 192.168.0.111 #5354 dns-dnsmasq_1 | dnsmasq: read /etc/hosts - 7 addresses dns-dnsmasq_1 | dnsmasq: query[A] www.google.com from 192.168.0.111 # 请求发送给了上游dns服务器,无后续reply。再去看上游dns服务器,发现已经解析出了ip # 而dnsmasq还是无应答 dns-dnsmasq_1 | dnsmasq: forwarded www.google.com to 192.168.0.111 dns-dnsmasq_1 | dnsmasq: query[A] www.google.com from 192.168.0.111 dns-dnsmasq_1 | dnsmasq: forwarded www.google.com to 192.168.0.111 |
1 | 尝试了很多方法,很奇怪它为什么不能应答。dnsmasq也不大,放在宿主机上运行吧。 |
1 2 3 4 | docker exec -it deac /bin/bash bash -4.3$ ping 192.168.1.100 PING 192.168.1.100 (192.168.10.100): 56 data bytes ping : permission denied (are you root?) |
1 2 | bash -4.3$ whoami jenkins |
1 2 3 4 5 6 7 | # 查看ping权限 bash -4.3 # ls -lsh /bin/ping 0 lrwxrwxrwx 1 root root 12 May 9 2017 /bin/ping -> /bin/busybox #查看ping连接文件的权限 bash -4.3$ ls -lhs /bin/busybox 804K -rwr-xr-x 1 root root 803K Oct 26 2016 /bin/busybox |
1 | docker exec -u root -it deac /bin/bash |
1 2 3 4 5 6 | #添加权限 chmod u+s /bin/ping # 让用户在执行ping时,暂时拥有权限 #再查看权限 bash -4.3$ ls -lsh /bin/busybox 804K -rwsr-xr-x 1 root root 803K Oct 26 2016 /bin/busybox |
1.选择apline作为基础镜像
2.合并dockerfile中RUN命令
3.安装软件后,删掉源文件
4.导出的文件用gzip命令压缩
5.save命令多个镜像一起导出,缩小整体大小
1 2 3 | FROM scratch ADD rootfs. tar .xz / CMD [ "/bin/sh" ] |
1 2 3 | FROM scratch ADD rootfs. tar .xz / CMD [ "bash" ] |
1 2 3 4 5 6 7 8 9 | FROM scratch ADD centos-7.4.1708-docker. tar .xz / LABEL name= "CentOS Base Image" \ vendor= "CentOS" \ license= "GPLv2" \ build- date = "20170911" CMD [ "/bin/bash" ] |
1 2 3 4 | * 显示官方 docker search [包名] --filter "is-official=true" * 过滤热度 docker search [包名] --stars=3 |