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 .