Dockerfile
FROM alpine:latest
RUN apk add --no-cache mysql-client
COPY keep.sh /keep.sh
RUN chmod a+x /keep.sh
CMD ["sh","/keep.sh"]
keep.sh
如果没有后台程序,docker会在退出交互界面后自动回收容器,如果想一直挂在后台运行,需要设置一个后台进程,如上代码块中的脚本仅作为保活使用,无实际意义。
#!/bin/sh
while true
do
sleep 60
done
构建镜像
docker build . -t test:0.0.1
一些Dockerfile
nps
FROM alpine:latest
EXPOSE 8888
ADD linux_amd64_server.tar.gz /nps
COPY nps.conf /nps/conf/nps.conf
RUN chmod a+x /nps/nps
CMD ["/nps/nps"]