方法一:使用Dockerhub(公共Registry)保存和分发镜像
1.首先在https://hub.docker.com注册个账号
2.使用步骤1中注册的账号登录dockerhub
docker login -u 用户名
3.使用docker tag修改自定义镜像名,镜像的registry中要包含用户名,完整格式为:[username]/xxx:tag
4.通过docker push将镜像上传到Dockerhub
5.登录https://hub.docker.com可查看上传的镜像,如果要删除镜像的话只能在界面上操作
附上述镜像的目录结构:
# Dockerfile的文件内容
FROM jenkins/jenkins:lts-centos MAINTAINER wangmengmeng USER root RUN yum install -y gcc zlib-devel make wget nmap tree which lsof net-tools openssl openssh-clients openssh-server sudo dmidecode gettext && yum reinstall -y glibc-common && yum -y clean all && rm -rf /var/cache/yum/* ADD jdk-8u201-linux-x64.tar.gz /usr/java/ ENV JAVA_HOME=/usr/java/jdk1.8.0_201 ENV PATH="${JAVA_HOME}/bin:${PATH}" RUN mkdir -p /python ADD Python-3.6.1.tgz /python/ WORKDIR /python/Python-3.6.1 RUN pwd && ls RUN /python/Python-3.6.1/configure --prefix=/usr/local/python3.6 --enable-optimizations RUN make && make install ENV PATH=/usr/local/python3.6/bin:$PATH RUN ln -s /usr/local/python3.6/bin/pip3 /usr/bin/pip3 RUN ln -s /usr/local/python3.6/bin/python3 /usr/bin/python3
使用该镜像来运行容器:
方法二:搭建本地Registry
后续补充介绍