对docker一部分问题的处理
- 一、permission denied
- 二、启动容器后又立即停止
- 三、Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
一、permission denied
- 当要执行
docker images
报错:Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json?all=1": dial unix /var/run/docker.sock: connect: permission denied
- 解决方案:加上sudo
sudo docker images
二、启动容器后又立即停止
- 原来的指令
docker run --name nginx -p 8080:80 -d -v /root/backend:/www/backend -v /data/nginx/conf.d/:/etc/nginx/conf.d --link myphp-fpm:php nginx:1.21.4
- 解决方案:
# 删除原来的
docker rm 容器ID
# 在运行的时候加上 -dit 和 /bin/bash
docker run --name nginx -p 8080:80 -dit -v /root/backend:/www/backend -v /data/nginx/conf.d/:/etc/nginx/conf.d --link myphp-fpm:php nginx:1.21.4 /bin/bash
三、Error: Failed to download metadata for repo ‘appstream’: Cannot prepare internal mirrorlist: No URLs in mirrorlist
新建一个centos容器,出现报错:Error: Failed to download metadata for repo ‘appstream’: Cannot prepare internal mirrorlist: No URLs in mirrorlist
- 解决方法
ping百度能ping通,不是网络问题。
执行以下指令,更改centos配置
cd /etc/yum.repos.d/
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
yum makecache
yum update -y