docker存储
#创建定时任务
vim my-cron
*/1 * * * * date >> /app/test.txt
#创建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"]
#构建镜像
docker image build -t my-cron .
#启动容器
docker container run -d -v cron-data:/app my-cron
#查看数据卷
docker volume ls
#查看数据卷位置
docker volume inspect cron-data
#强制删除所有容器,系统清理和volume清理
docker rm -f $(docker container ps -aq)
docker system prune -f
docker volume prune -f
docker volume mysql
docker pull mysql:5.7
docker container run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d -v mysql-data:/var/lib/mysql mysql:5.7
docker exec -it 50 /bin/bash
docker volume inspect mysql-data