开发常用
镜像选择
尽量选择 Alpine
版本,体积小,使用apk
安装依赖,如 apk add --no-cache gcc g++ python2
如需要python2,尽量使用 alpine 3.14 左右的版本
alpine 设置时区
apk add --no-cache tzdata
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' > /etc/timezone
dockerfile
# Use the official Alpine image
FROM alpine:latest
# Set the environment variable for the timezone
ENV TZ=UTC
#ENV TZ=Asia/Shanghai
# Install tzdata package for timezone data
RUN apk add --no-cache tzdata
# Set the timezone
RUN cp /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# Verify the timezone is set correctly
RUN date
# Your application setup goes here
# ...
# Example entrypoint
CMD ["sh"]
postgres
podman run --rm -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=hello_dev postgres:12.19-alpine