环境
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
636aa46e986a nginx "/docker-entrypoint.…" 20 hours ago Up 20 hours 0.0.0.0:80->80/tcp dev-nginx
9d904727fd88 php:5.6-fpm "docker-php-entrypoi…" 20 hours ago Up 20 hours 9000/tcp php56fpm
打开一个容器的终端
docker exec -it php56fpm /bin/bash
以下均在容器的终端里操作
备份
cp /etc/apt/sources.list /etc/apt/sources.list.bak
写入国内源
echo 'deb http://mirrors.163.com/debian/ stretch main non-free contrib' > /etc/apt/sources.list
echo 'deb http://mirrors.163.com/debian/ stretch-updates main non-free contrib' >> /etc/apt/sources.list
echo 'deb http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib' >> /etc/apt/sources.list
更新
apt-get update
安装示例
apt-get install libssl-dev
感受一下速度吧
Alpine apk国内仓库
进入容器后运行以下命令
sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
然后更新
apk update
网友评论