docker 学习:发布自己的 image 镜像
发布自己常用的 image
步骤
写一个简单的 docker-ubuntu 镜像
# 1. 注册自己的账号,并登录
docker login
# 2. 写 Dockerfile
FROM ubuntu:20.04
# 1. apt update
# 2. apt install vim -y
RUN apt update && apt install vim -y
# 3. build image
docker build -t afeiship/docker-ubuntu .
# 4. push 到镜像源
# 4.1 推送到自定义源
docker push registry.cn-hangzhou.aliyuncs.com/google_containers/pause-amd64:3.1
# 4.1 推送到官方源
docker push afeiship/docker-ubuntu
ubuntu 换源 20.04
RUN sed -i s/archive.ubuntu.com/mirrors.aliyun.com/g /etc/apt/sources.list \
&& sed -i s/security.ubuntu.com/mirrors.aliyun.com/g /etc/apt/sources.list \
&& apt-get update && apt-get upgrade
ubuntu 换源 18.04
RUN sed -i s/deb.debian.org/mirrors.aliyun.com/g /etc/apt/sources.list \
&& sed -i s/security.debian.org/mirrors.aliyun.com/g /etc/apt/sources.list \
&& apt-get update && apt-get upgrade
Google 报错
GPG error: http://packages.cloud.google.com/apt cloud-sdk-stretch InRelease:
The following signatures were invalid: EXPKEYSIG 3746C208A7317B0F
# 重新生成即可
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
设置时区
# 查看
ls -l /etc/localtime
# 查看时间
date
# 设置(-s/-f: 强制)
ln -s -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# 在 docker 中设置就这一句
ENV TZ Asia/Shanghai
docker 本身更新源
"registry-mirrors": [
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com"
]
删除所有 containers
docker rm $(docker ps -a -q)
参考