docker(22) : arm架构ubuntu镜像拉取

拉取镜像

docker pull arm64v8/ubuntu:20.04

创建文件(直接粘贴)


cat > ubuntu_test_image_dockerfile <<'EOF'
FROM arm64v8/ubuntu:20.04

# 设定时区
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

CMD ["sh","/home/startup.sh"]
EOF


cat > startup.sh <<'EOF'
while true
do
    date
    sleep 20s
done
EOF

docker build -t ubuntu_test:1.0 -f ubuntu_test_image_dockerfile .

cat > bin.sh<<'EOF'
case "$1" in
    start)
        docker start ubuntu_test
        ;;
    stop)
        docker stop ubuntu_test
        ;;
    restart)
        docker restart ubuntu_test
        ;;
    exec)
        docker exec -it ubuntu_test bash
        ;;
    rm)
        docker rm -f ubuntu_test
        ;;
    log)
        docker logs -f --tail 100 ubuntu_test
        ;;
    *)
        echo "start|stop|restart|log"
        ;;
esac
EOF

cat > run.sh <<'EOF'

path="$( cd "$( dirname "$0"  )" && pwd  )"
docker run -d --name=ubuntu_test --log-opt max-size=10m --log-opt max-file=3 \
          --restart=always \
          -v $path:/home \
          -v /etc/localtime:/etc/localtime \
          -v $path/log:/logs \
          -p 8080:8080 ubuntu_test:1.0
EOF

chmo +x *.sh

启动

./run.sh

查看日志

./bin.sh log

你可能感兴趣的:(docker,docker,ubuntu,容器,arm,ubuntu时区设置)