docker初体验:docker 自己定制镜像

环境
centos7
安装docker
移除旧版本docker
[root@chaols ~]# sudo yum remove docker \ > docker-client \ > docker-client-latest \ > docker-common \ > docker-latest \ > docker-latest-logrotate \ > docker-logrotate \ > docker-engine
安装yum-utils包并设置稳定存储库
[root@chaols ~]# yum install -y yum-utils
安装docker
[root@chaols ~]# yum install docker-ce docker-ce-cli containerd.io
启动docker
[root@chaols ~]# systemctl start docker
查看docker镜像
刚刚安装docker是没有镜像的
[root@chaols ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE
下载centos镜像
[root@chaols ~]# docker pull centos
默认centos镜像没有ifconfig
自定义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"
开始制作
docker build -f ./dockerfile_chao_centos -t chao.centos:0.1 .
创建虚拟机
root@chaols ~]# docker run -it --name test chao.centos:0.1 /bin/bash
验证ifconfig
[root@f5be14eebc1e local]# ifconfig eth0: flags=4163 mtu 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=73 mtu 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
本文原创地址:https://www.linuxprobe.com/docker-docker-images.html编辑:王华超,审核员:逄增宝
为您推荐一些与本文相关的文章:
- 详解MySQL性能指标及计算方法
- 新的Firefox来了!48版本将支持多进程架构
- 系统管理员不容错过的十款卓越开源工具
- 运维需要掌握的12个路由知识点
- Qt Creator 4.9 发布
- 2016 杭州云栖盛会分享
- 更有效的使用shell
- 历经六个多月,Hyper-V Server 2019来了
- 微软发布分析应用:将为Win10搜索问题带来解决方案
- 无处遁形的隐私