1、将docker 在使用前将images源改为国内源,社区源下载比较慢
"registry-mirrors": [
"http://hub-mirror.c.163.com"
],
[root@host-191-168-1-172 docker_learn]# cat /etc/docker/daemon.json
{
"registry-mirrors": [
"http://hub-mirror.c.163.com"
],
"bip": "172.172.0.1/16",
"storage-driver":"overlay2",
"storage-opts":[
"overlay2.override_kernel_check=true",
"overlay2.size=20G"
],
"log-level": "fatal",
"log-opts": {"max-size":"100m"},
"graph": "/var/lib/placements/docker"
更改images源后重启docker 服务 systemctl restart docker
2、Dockerfile内容
FROM centos
ENV MY_PATH /user/local
WORKDIR $MY_PATH
RUN echo net.ipv4.ip_forward=1 >> /etc/sysctl.conf
#RUN yum install -y vim //在实际的使用过程中超时,可在镜像制作好后手动执行
#RUN yum install -y net-tools //在实际的使用过程中超时,可在镜像制作好后手动执行
CMD /bin/bash
3、进行镜像制作
docker build -f Dockerfile -t centos-base .