1
环 境
2
安装 docker
[root@chaols ~]# sudo yum remove docker \
> docker-client \
> docker-client-latest \
> docker-common \
> docker-latest \
> docker-latest-logrotate \
> docker-logrotate \
> docker-engine
[root@chaols ~]# yum install -y yum-utils
[root@chaols ~]# yum install docker-ce docker-ce-cli containerd.io
3
启动 docker
[root@chaols ~]# systemctl start docker
4
查看 docker 镜像
[root@chaols ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
5
下载 centos 镜像
[root@chaols ~]# docker pull centos
6
自定义 dockerfile 文件
FROM centos
ENV MYPATH /usr/local
WORKDIR $MYPATH
RUN yum install -y net-tools
RUN yum install -y vim
EXPOSE 80
CMD echo $MYPATH
CMD echo "-----end-----"
CMD /bin/bash"
7
开始制作
docker build -f ./dockerfile_chao_centos -t chao.centos:0.1 .
8
创建虚拟机
root@chaols ~]# docker run -it --name test chao.centos:0.1 /bin/bash
9
验证 ifconfig
[root@f5be14eebc1e local]# ifconfig
eth0: flags=4163mtu 1500
inet 172.17.0.2 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:ac:11:00:02 txqueuelen 0 (Ethernet)
RX packets 6 bytes 516 (516.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
END
官方站点:www.linuxprobe.com
Linux命令大全:www.linuxcool.com
刘遄老师QQ:5604922
Linux技术交流群:193666693
(新群,火热加群中……)
想要学习Linux系统的读者可以点击"阅读原文"按钮来了解书籍《Linux就该这么学》,同时也非常适合专业的运维人员阅读,成为辅助您工作的高价值工具书!
文章评论