docker 容器替换其它源的最佳方式

No Comments 容器技术

启动
docker run -itd -p 808:8080  jefftomcat:v2 /bin/bash
看进程
docker ps
将apt/source.list复制到本地服务器

docker cp 容器ID:/容器目录  地本目录

docker cp 81128bff7253:/etc/apt/ tmp
 
编辑source.list文件
docker cp sources.list 81128bff7253:/etc/apt/
docker attach 81128bff7253
vim sources.list
复制回去
docker cp sources.list 81128bff7253:/etc/apt/
直接进去更新

docker attach 容器ID
docker attach 81128bff7253
  root@81128bff7253:/usr/local/tomcat/bin#  apt-get update

内容如下
deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb http://mirrors.aliyun.com/debian-security stretch/updates main
deb-src http://mirrors.aliyun.com/debian-security stretch/updates main
deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib

发表评论