在CentOS7中按老师的操作并没有生成output.txt文件,请老师帮忙看下哪里的操作有问题哈。
[root@server1 my-cron]# touch my-cron
[root@server1 my-cron]# ls
Dockerfile my-cron
[root@server1 my-cron]# more Dockerfile
Dockerfile文件内容如下:
FROM alpine:latest
RUN apk update
RUN apk --no-cache add curl
ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.12/supercronic-linux-amd64 \
SUPERCRONIC=supercronic-linux-amd64 \
SUPERCRONIC_SHA1SUM=048b95b48b708983effb2e5c935a1ef8483d9e3e
RUN curl -fsSLO "$SUPERCRONIC_URL" \
&& echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \
&& chmod +x "$SUPERCRONIC" \
&& mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \
&& ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic
COPY my-cron /app/my-cron
WORKDIR /app
# RUN cron job
CMD ["/usr/local/bin/supercronic", "/app/my-cron"]
执行构建和运行:
[root@server1 my-cron]# docker image build -t my-cron .
[root@server1 my-cron]# docker run -d my-cron
161b2644d584843b49c6d306efa9a91470866da864afacf95e5ff19ee2bad0b4
[root@server1 my-cron]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
161b2644d584 my-cron "/usr/local/bin/supe…" 13 seconds ago Up 12 seconds ecstatic_borg
[root@server1 my-cron]# docker exec -it 161 sh
/app # ls
my-cron
/app # more my-cron
/app #
并没有和在老师视频中看到的那样,容器内的/app
目录下会生成一个output.txt
文件来写入时间/(ㄒoㄒ)/~~