I need to rewrite a Dockerfile to create my own Dockerfile. I pull a docker image base from dockerhub first.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 FROM balenalib/raspberry-pi-alpine:3.9 LABEL org.opencontainers.image.authors="Tobias Hargesheimer <docker@ison.ws>" \ org.opencontainers.image.title="NGINX" \ org.opencontainers.image.description="AlpineLinux with NGINX on arm arch" \ org.opencontainers.image.licenses="Apache-2.0" \ org.opencontainers.image.url="https://hub.docker.com/r/tobi312/rpi-nginx/" \ org.opencontainers.image.source="https://github.com/Tob1asDocker/rpi-nginx" ARG CROSS_BUILD_START=":" ARG CROSS_BUILD_END=":" RUN [ ${CROSS_BUILD_START} ] ENV NGINX_VERSION 1.14 RUN apk --no-cache add nginx>${NGINX_VERSION} \ && mkdir -p /run/nginx \ && sed -i "s/ssl_session_cache shared:SSL:2m;/#ssl_session_cache shared:SSL:2m;/g" /etc/nginx/nginx.conf # forward request and error logs to docker log collector RUN ln -sf /dev/stdout /var/log/nginx/access.log \ && ln -sf /dev/stderr /var/log/nginx/error.log # fix: *** stack smashing detected ***: nginx: worker process terminated / [alert] 9#9: worker process *process-id* exited on signal 6 #RUN sed -i "s/worker_processes auto;/worker_processes 1;/g" /etc/nginx/nginx.conf EXPOSE 80 443 CMD ["nginx", "-g", "daemon off;"] RUN [ ${CROSS_BUILD_END} ]
For this image, its base is balenalib/raspberry-pi-alpine:3.9. when I am going to build my own docker image, it has the newest version, but I still use the old one, because it will be more stable for me.
I add some new command unders this docker base Dockerfile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 FROM balenalib/raspberry-pi-alpine:3.9 LABEL org.opencontainers.image.authors="Tobias Hargesheimer <docker@ison.ws>" \ org.opencontainers.image.title="NGINX" \ org.opencontainers.image.description="AlpineLinux with NGINX on arm arch" \ org.opencontainers.image.licenses="Apache-2.0" \ org.opencontainers.image.url="https://hub.docker.com/r/tobi312/rpi-nginx/" \ org.opencontainers.image.source="https://github.com/Tob1asDocker/rpi-nginx" ARG CROSS_BUILD_START=":" ARG CROSS_BUILD_END=":" RUN [ ${CROSS_BUILD_START} ] ENV NGINX_VERSION 1.14 RUN apk --no-cache add nginx>${NGINX_VERSION} \ && mkdir -p /run/nginx \ && sed -i "s/ssl_session_cache shared:SSL:2m;/#ssl_session_cache shared:SSL:2m;/g" /etc/nginx/nginx.conf # forward request and error logs to docker log collector RUN ln -sf /dev/stdout /var/log/nginx/access.log \ && ln -sf /dev/stderr /var/log/nginx/error.log # fix: *** stack smashing detected ***: nginx: worker process terminated / [alert] 9#9: worker process *process-id* exited on signal 6 #RUN sed -i "s/worker_processes auto;/worker_processes 1;/g" /etc/nginx/nginx.conf EXPOSE 80 443 CMD ["nginx", "-g", "daemon off;"] RUN [ ${CROSS_BUILD_END} ] RUN apk add --no-cache \ fcgi=2.4.0-r8 \ fcgiwrap=1.1.0-r3 \ spawn-fcgi=1.6.4-r3 \ ca-certificates=20190108-r0 \ nghttp2-libs=1.35.1-r0 \ libssh2=1.8.2-r0 \ libcurl=7.64.0-r2 \ curl=7.64.0-r2 \ oniguruma=6.9.4-r0 \ jq=1.6-r0
Notice: the packages need to be installed all have version numbers which will cause the error in the following.
After modify the Dockerfile, I am going to build my docker image.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 root@vmnet8cloud:~/git_repo/preplanet/docker/planet# docker build -t vmnet8/preplanet:rpi-1 . Sending build context to Docker daemon 4.096kB Step 1/12 : FROM balenalib/raspberry-pi-alpine:3.9 ---> d6c5aebf964a Step 2/12 : LABEL org.opencontainers.image.authors="Tobias Hargesheimer <docker@ison.ws>" org.opencontainers.image.title="NGINX" org.opencontainers.image.description="AlpineLinux with NGINX on arm arch" org.opencontainers.image.licenses="Apache-2.0" org.opencontainers.image.url="https://hub.docker.com/r/tobi312/rpi-nginx/" org.opencontainers.image.source="https://github.com/Tob1asDocker/rpi-nginx" ---> Using cache ---> 1a8a69474af2 Step 3/12 : ARG CROSS_BUILD_START=":" ---> Using cache ---> 2ea7d76cc571 Step 4/12 : ARG CROSS_BUILD_END=":" ---> Using cache ---> 9dac95067f17 Step 5/12 : RUN [ ${CROSS_BUILD_START} ] ---> Using cache ---> e1d8ae03657f Step 6/12 : ENV NGINX_VERSION 1.14 ---> Using cache ---> 684896377216 Step 7/12 : RUN apk --no-cache add nginx>${NGINX_VERSION} && mkdir -p /run/nginx && sed -i "s/ssl_session_cache shared:SSL:2m;/#ssl_session_cache shared:SSL:2m;/g" /etc/nginx/nginx.conf ---> Using cache ---> ef20e56136c1 Step 8/12 : RUN ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log ---> Using cache ---> 8d95b6ad6846 Step 9/12 : EXPOSE 80 443 ---> Using cache ---> a12bf17fcaea Step 10/12 : CMD ["nginx", "-g", "daemon off;"] ---> Using cache ---> 1f6e9eb85851 Step 11/12 : RUN [ ${CROSS_BUILD_END} ] ---> Using cache ---> 969cc49b4faf Step 12/12 : RUN apk add --no-cache fcgi=2.4.0-r8 fcgiwrap=1.1.0-r3 spawn-fcgi=1.6.4-r3 ca-certificates=20190108-r0 nghttp2-libs=1.35.1-r0 libssh2=1.8.2-r0 libcurl=7.64.0-r2 curl=7.64.0-r2 oniguruma=6.9.4-r0 jq=1.6-r0 ---> Running in 910227bcece4 fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/armhf/APKINDEX.tar.gz fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/armhf/APKINDEX.tar.gz ERROR: unsatisfiable constraints: nghttp2-libs-1.35.1-r1: breaks: world[nghttp2-libs=1.35.1-r0] satisfies: libcurl-7.64.0-r3[so:libnghttp2.so.14] libssh2-1.9.0-r1: breaks: world[libssh2=1.8.2-r0] satisfies: libcurl-7.64.0-r3[so:libssh2.so.1] libcurl-7.64.0-r3: breaks: world[libcurl=7.64.0-r2] satisfies: curl-7.64.0-r3[so:libcurl.so.4] curl-7.64.0-r3: breaks: world[curl=7.64.0-r2] The command '/bin/sh -c apk add --no-cache fcgi=2.4.0-r8 fcgiwrap=1.1.0-r3 spawn-fcgi=1.6.4-r3 ca-certificates=20190108-r0 nghttp2-libs=1.35.1-r0 libssh2=1.8.2-r0 libcurl=7.64.0-r2 curl=7.64.0-r2 oniguruma=6.9.4-r0 jq=1.6-r0' returned a non-zero code: 4
It shows error.
I modified the Dockerfile again and move off all packages versions like following
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 FROM balenalib/raspberry-pi-alpine:3.9 LABEL org.opencontainers.image.authors="Tobias Hargesheimer <docker@ison.ws>" \ org.opencontainers.image.title="NGINX" \ org.opencontainers.image.description="AlpineLinux with NGINX on arm arch" \ org.opencontainers.image.licenses="Apache-2.0" \ org.opencontainers.image.url="https://hub.docker.com/r/tobi312/rpi-nginx/" \ org.opencontainers.image.source="https://github.com/Tob1asDocker/rpi-nginx" ARG CROSS_BUILD_START=":" ARG CROSS_BUILD_END=":" RUN [ ${CROSS_BUILD_START} ] ENV NGINX_VERSION 1.14 RUN apk --no-cache add nginx>${NGINX_VERSION} \ && mkdir -p /run/nginx \ && sed -i "s/ssl_session_cache shared:SSL:2m;/#ssl_session_cache shared:SSL:2m;/g" /etc/nginx/nginx.conf # forward request and error logs to docker log collector RUN ln -sf /dev/stdout /var/log/nginx/access.log \ && ln -sf /dev/stderr /var/log/nginx/error.log # fix: *** stack smashing detected ***: nginx: worker process terminated / [alert] 9#9: worker process *process-id* exited on signal 6 #RUN sed -i "s/worker_processes auto;/worker_processes 1;/g" /etc/nginx/nginx.conf EXPOSE 80 443 CMD ["nginx", "-g", "daemon off;"] RUN [ ${CROSS_BUILD_END} ] RUN apk add --no-cache \ fcgi \ fcgiwrap \ spawn-fcgi \ ca-certificates \ nghttp2-libs \ libssh2 \ libcurl \ curl \ oniguruma \ jq
then build docker image again
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 root@vmnet8cloud:~/git_repo/preplanet/docker/planet# docker build -t vmnet8/preplanet:rpi-1 . Sending build context to Docker daemon 6.144kB Step 1/12 : FROM balenalib/raspberry-pi-alpine:3.9 ---> d6c5aebf964a Step 2/12 : LABEL org.opencontainers.image.authors="Tobias Hargesheimer <docker@ison.ws>" org.opencontainers.image.title="NGINX" org.opencontainers.image.description="AlpineLinux with NGINX on arm arch" org.opencontainers.image.licenses="Apache-2.0" org.opencontainers.image.url="https://hub.docker.com/r/tobi312/rpi-nginx/" org.opencontainers.image.source="https://github.com/Tob1asDocker/rpi-nginx" ---> Using cache ---> 1a8a69474af2 Step 3/12 : ARG CROSS_BUILD_START=":" ---> Using cache ---> 2ea7d76cc571 Step 4/12 : ARG CROSS_BUILD_END=":" ---> Using cache ---> 9dac95067f17 Step 5/12 : RUN [ ${CROSS_BUILD_START} ] ---> Using cache ---> e1d8ae03657f Step 6/12 : ENV NGINX_VERSION 1.14 ---> Using cache ---> 684896377216 Step 7/12 : RUN apk --no-cache add nginx>${NGINX_VERSION} && mkdir -p /run/nginx && sed -i "s/ssl_session_cache shared:SSL:2m;/#ssl_session_cache shared:SSL:2m;/g" /etc/nginx/nginx.conf ---> Using cache ---> ef20e56136c1 Step 8/12 : RUN ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log ---> Using cache ---> 8d95b6ad6846 Step 9/12 : EXPOSE 80 443 ---> Using cache ---> a12bf17fcaea Step 10/12 : CMD ["nginx", "-g", "daemon off;"] ---> Using cache ---> 1f6e9eb85851 Step 11/12 : RUN [ ${CROSS_BUILD_END} ] ---> Using cache ---> 969cc49b4faf Step 12/12 : RUN apk add --no-cache fcgi fcgiwrap spawn-fcgi ca-certificates nghttp2-libs libssh2 libcurl curl oniguruma jq ---> Running in 95d22279f720 fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/armhf/APKINDEX.tar.gz fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/armhf/APKINDEX.tar.gz (1/5) Installing fcgi (2.4.0-r8) (2/5) Installing fcgiwrap (1.1.0-r3) Executing fcgiwrap-1.1.0-r3.pre-install (3/5) Installing oniguruma (6.9.4-r0) (4/5) Installing jq (1.6-r0) (5/5) Installing spawn-fcgi (1.6.4-r3) Executing busybox-1.29.3-r10.trigger OK: 52 MiB in 77 packages Removing intermediate container 95d22279f720 ---> 7ee7b73f89ee Successfully built 7ee7b73f89ee Successfully tagged vmnet8/preplanet:rpi-1
After building, test the running container
1 2 3 4 5 6 7 8 9 10 11 12 13 14 run docer image vmnet8/preplanet:rpi-1 root@vmnet8cloud:~/git_repo/preplanet/docker/planet# docker run -d vmnet8/preplanet:rpi-1 b974aee9b9bb0d6242dcbab12e975585ff1e2d4b887860523b6d0b261863d562 root@vmnet8cloud:~/git_repo/preplanet/docker/planet# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b974aee9b9bb vmnet8/preplanet:rpi-1 "/usr/bin/entry.sh n…" 9 seconds ago Up 7 seconds 80/tcp, 443/tcp goofy_banach 270cf6e3e185 vmnet8/preplanet:rpi-1 "/usr/bin/entry.sh n…" 2 minutes ago Exited (0) About a minute ago cranky_wing 7259cecd0e74 969cc49b4faf "/bin/sh -c 'apk add…" 11 hours ago Exited (99) 11 hours ago dreamy_brown 910227bcece4 969cc49b4faf "/bin/sh -c 'apk add…" 11 hours ago Exited (4) 11 hours ago modest_wu d4f32b1bc836 68513e2e4bce "/bin/sh -c 'apk add…" 14 hours ago Exited (6) 14 hours ago frosty_herschel baa0a10c37a7 324ab2e7954e "/bin/sh -c 'bash ./…" 4 weeks ago Exited (127) 4 weeks ago cranky_herschel b5ba36510956 vmnet8/preplanet:rpi "/usr/bin/entry.sh n…" 4 weeks ago Up 4 weeks 443/tcp, 0.0.0.0:20006->80/tcp heuristic_chaplygin 201,0-1 Bot
It shows it works.