VirtualBox Euleros 虚拟机 安装docker-ce

原创
02/14 22:51
阅读数 750

一、安装:

sudo wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.huaweicloud.com/docker-ce/linux/centos/docker-ce.repo
sudo sed -i 's+download.docker.com+mirrors.huaweicloud.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo
sudo yum makecache fast
sudo yum install docker-ce

sudo rpm -ivh https://mirrors.huaweicloud.com/epel/epel-release-latest-7.noarch.rpm
sudo cp -a /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
sudo mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup
sudo sed -i "s/#baseurl/baseurl/g" /etc/yum.repos.d/epel.repo
sudo sed -i "s/mirrorlist/#mirrorlist/g" /etc/yum.repos.d/epel.repo
sudo sed -i "s@http://download.fedoraproject.org/pub@https://mirrors.huaweicloud.com@g" /etc/yum.repos.d/epel.repo

# sudo yum install container-selinux  
wget -O docker-ce.repo https://mirrors.huaweicloud.com/docker-ce/linux/centos/docker-ce.repo
wget -O epel-release-latest-7.noarch.rpm https://mirrors.huaweicloud.com/epel/epel-release-latest-7.noarch.rpm
wget -O container-selinux-2.107-3.el7.noarch.rpm https://mirrors.huaweicloud.com/centos/7/extras/x86_64/Packages/container-selinux-2.107-3.el7.noarch.rpm
wget -O selinux-policy-3.13.1-252.el7.noarch.rpm http://mirrors.huaweicloud.com/centos/7/os/x86_64/Packages/selinux-policy-3.13.1-252.el7.noarch.rpm
wget -O selinux-policy-targeted-3.13.1-252.el7.noarch.rpm http://mirrors.huaweicloud.com/centos/7/os/x86_64/Packages/selinux-policy-targeted-3.13.1-252.el7.noarch.rpm
wget -O policycoreutils-2.5-33.el7.x86_64.rpm http://mirrors.huaweicloud.com/centos/7/os/x86_64/Packages/policycoreutils-2.5-33.el7.x86_64.rpm
wget -O libselinux-utils-2.5-14.1.el7.x86_64.rpm http://mirrors.huaweicloud.com/centos/7/os/x86_64/Packages/libselinux-utils-2.5-14.1.el7.x86_64.rpm
wget -O libsemanage-2.5-14.el7.x86_64.rpm http://mirrors.huaweicloud.com/centos/7/os/x86_64/Packages/libsemanage-2.5-14.el7.x86_64.rpm
wget -O policycoreutils-2.5-33.el7.x86_64.rpm http://mirrors.huaweicloud.com/centos/7/os/x86_64/Packages/policycoreutils-2.5-33.el7.x86_64.rpm
wget -O libselinux-2.5-14.1.el7.x86_64.rpm http://mirrors.huaweicloud.com/centos/7/os/x86_64/Packages/libselinux-2.5-14.1.el7.x86_64.rpm
wget -O libsepol-2.5-10.el7.x86_64.rpm http://mirrors.huaweicloud.com/centos/7/os/x86_64/Packages/libsepol-2.5-10.el7.x86_64.rpm
sudo rpm -ivh --force libsepol-2.5-10.el7.x86_64.rpm
sudo rpm -ivh --force libselinux-2.5-14.1.el7.x86_64.rpm
sudo rpm -ivh --force libsemanage-2.5-14.el7.x86_64.rpm
sudo rpm -ivh --force libsemanage-2.5-14.el7.x86_64.rpm
sudo rpm -ivh --force libselinux-utils-2.5-14.1.el7.x86_64.rpm
sudo rpm -ivh --force policycoreutils-2.5-33.el7.x86_64.rpm
sudo rpm -ivh --force selinux-policy-3.13.1-252.el7.noarch.rpm
sudo rpm -ivh --force selinux-policy-targeted-3.13.1-252.el7.noarch.rpm
sudo rpm -ivh container-selinux-2.107-3.el7.noarch.rpm

sudo yum install docker-ce --downloadonly --downloaddir=./
sudo yum install -y docker-ce
sudo systemctl enable docker 
sudo groupadd docker
sudo reboot

二、验证

docker images
docker pull hello-world
docker images
docker run hello-world
docker ps -a
docker ps -a |grep hello-world|awk '{print "docker rm "$1}'|sh
docker images|grep  hello-world|awk '{print "docker rmi "$3}'|sh

三、出现的问题处理

1、没有创建docker组,报错,错误如下:

sudo systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: https://docs.docker.com

2月 14 22:01:23 self-work.euleros systemd[1]: Dependency failed for Docker Application Container Engine.
2月 14 22:01:23 self-work.euleros systemd[1]: Job docker.service/start failed with result 'dependency'.

解决:

sudo groupadd docker
sudo systemctl restart docker

2、在普通用户下执行docker,出现权限问题,生产慎用,该权限如同root。错误描述如下:

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.40/images/json: dial unix /var/run/docker.sock: connect: permission denied
永久解决方案:

your_user_name=$(whoami)
sudo usermod -aG docker $your_user_name
sudo reboot

临时解决方案,重启后失效:

sudo chmod a+wr /var/run/docker.sock

 

 

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部