问题描述
- 在docker部署的容器中有用到netstat命令,但是会报/bin/bash: netstat: command not found这个错误
解决方案
1、docker容器中很多命令都是没有的,需要自己进行安装包。出现上述问题是因为缺少net-tools包。所以执行需要执行以下命令:
apt-get update
apt-get install net-tools
2、在执行过程中遇到了权限不够的bug:E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied)
2.1解决方案:使用root用户登录
- 首先输入exit命令退出,然后输入
docker exec -it -u 0 xxxxx
【-u 0的意思就是以root用户登录】 - root用户登录之后再执行1当中的步骤
3、发现apt-get update命令下载的速度很慢,考虑换源
3.1解决方案:
#首先进入到/etc/apt/目录下
cd /etc/apt
#然后拷贝原先的源文件
cp sources.list sources.list.bak
#接着将sources.list文件中内容换为阿里云的源
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
再重新执行apt-get update命令,发现执行速度快了很多