manjaro安装docker并设置
1.安装docker
sudo pacman -S docker
2. 启动服务并添加至系统
sudo systemctl start docker.service #start service
sudo systemctl enable docker.service #enable system service
3. 查验docker版本
sudo docker version
4. 查看docker信息
sudo docker info
5. 若有错误出现:ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
需要重新启动docker服务即可
6. docker下的helloworld
sudo docker pull hello-world #first terminal
sudo docker run hello-world #second terminal
7. 查看docker容器
sudo docker ps -a #结果:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
990012f7a01a hello-world "/hello" 3 minutes ago Exited (0) 3 minutes ago inspiring_jones
8. 删除指定容器的id
sudo docker rm -f <containerid>
若想删除以上的容器,则:
sudo docker rm -f 990012f7a01a
再次查看:
sudo docker ps -a #结果:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
是不是发现每次执行docker时都要加上sudo啊,很不方便:将当前用户加入docker用户组即可
9. 添加用户到docker用户组
sudo gpasswd -a $USER docker
newgrp docker
10. 如果docker容器挂了,出现运行命令docker ps,提示:cannot connect to the docker daemon at unix ///var/run/docker.sock. Is the docker daemon running? 先说解决方案:启动docker daemon:
sudo dockerd