mac中的linux虚拟机里安装docker
1.yum install -y yum-utils 2.yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo --配置阿里云仓库 3.yum makecache 4.yum install docker-ce -y 5.docker version --查看是否安装成功 6.systemctl start docker --启动docker 7.systemctl restart docker --重启docker
安装遇到的问题
Error: Problem 1: problem with installed package podman-2.0.5-5.module_el8.3.0+512+b3b58dca.x86_64 - package podman-2.0.5-5.module_el8.3.0+512+b3b58dca.x86_64 requires runc >= 1.0.0-57, but none of the providers can be installed - package podman-2.2.1-7.module_el8.3.0+699+d61d9c41.x86_64 requires runc >= 1.0.0-57, but none of the providers can be installed - package containerd.io-1.4.4-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-68.rc92.module_el8.3.0+475+c50ce30b.x86_64 - package containerd.io-1.4.4-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-68.rc92.module_el8.3.0+475+c50ce30b.x86_64 - package containerd.io-1.4.4-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-70.rc92.module_el8.3.0+699+d61d9c41.x86_64 - package containerd.io-1.4.4-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-70.rc92.module_el8.3.0+699+d61d9c41.x86_64 - cannot install the best candidate for the job - package runc-1.0.0-64.rc10.module_el8.3.0+479+69e2ae26.x86_64 is filtered out by modular filtering Problem 2: problem with installed package buildah-1.15.1-2.module_el8.3.0+475+c50ce30b.x86_64 - package buildah-1.15.1-2.module_el8.3.0+475+c50ce30b.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed - package buildah-1.16.7-4.module_el8.3.0+699+d61d9c41.x86_64 requires runc >= 1.0.0-26, but none of the providers can be installed - package docker-ce-3:20.10.6-3.el8.x86_64 requires containerd.io >= 1.4.1, but none of the providers can be installed - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-70.rc92.module_el8.3.0+699+d61d9c41.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-70.rc92.module_el8.3.0+699+d61d9c41.x86_64 - package containerd.io-1.4.3-3.2.el8.x86_64 conflicts with runc provided by runc-1.0.0-70.rc92.module_el8.3.0+699+d61d9c41.x86_64 - package containerd.io-1.4.3-3.2.el8.x86_64 obsoletes runc provided by runc-1.0.0-70.rc92.module_el8.3.0+699+d61d9c41.x86_64 - package containerd.io-1.4.4-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-70.rc92.module_el8.3.0+699+d61d9c41.x86_64 - package containerd.io-1.4.4-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-70.rc92.module_el8.3.0+699+d61d9c41.x86_64 - cannot install the best candidate for the job - package containerd.io-1.4.3-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-68.rc92.module_el8.3.0+475+c50ce30b.x86_64 - package containerd.io-1.4.3-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-68.rc92.module_el8.3.0+475+c50ce30b.x86_64 - package containerd.io-1.4.3-3.2.el8.x86_64 conflicts with runc provided by runc-1.0.0-68.rc92.module_el8.3.0+475+c50ce30b.x86_64 - package containerd.io-1.4.3-3.2.el8.x86_64 obsoletes runc provided by runc-1.0.0-68.rc92.module_el8.3.0+475+c50ce30b.x86_64 - package containerd.io-1.4.4-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-68.rc92.module_el8.3.0+475+c50ce30b.x86_64 - package containerd.io-1.4.4-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-68.rc92.module_el8.3.0+475+c50ce30b.x86_64 - package runc-1.0.0-56.rc5.dev.git2abd837.module_el8.3.0+569+1bada2e4.x86_64 is filtered out by modular filtering - package runc-1.0.0-64.rc10.module_el8.3.0+479+69e2ae26.x86_64 is filtered out by modular filtering (try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
关于这个问题
查看是否安装 Podman
rpm -q podman
podman-1.4.2-5.module_el8.1.0+237+63e26edc.x86_64
删除Podman
dnf remove podman
还有一个buildah
也是这样的操作
查看是否安装 buildah
rpm -q buildah
删除buildah
dnf remove buildah
未找到容器:容器启动失败

把dataease的数据配置改为内部数据库重新离线安装,后

启动 Docker
sudo systemctl start docker
1
拉取容器
docker pull redis:latest
1
Docker 命令
镜像
docker images 查看容器
docker rmi [镜像id] 删除镜像
docker rmi redis
容器
docker ps 查看启动镜像
docker ps -a 查看所有镜像
docker start [容器id/容器别名] 启动容器
docker start nginx-2
docker stop [容器id/容器别名] 停止容器
docker stop nginx-2
docker restart [容器id/容器别名] 重启容器
docker restart nginx-2
docker exec -it [容器id/容器别名]:TAG /bin/bash 进入容器
docker exec -it nginx-2 /bin/bash
docker rm -f [容器id/容器别名] 删除容器
docker rm -f nginx-2
docker run -d -p :启动容器
-d 表示后台运行 -p 表示端口映射
docker port 查看容器端口映射信息
docker port nginx-2
docker logs 查看容器日志信息
docker logs nginx-2
docker top 查看容器运行的进程
docker top nginx-2
docker inspect 查看容器信息
- docker inspect nginx-2
docker 中不能用vim编辑文件
更新来源
apt-get update
安装vim
apt-get install -y vim
docker导入导出
导出:> 目录/文件名.tar
docker export nginx-2 > /nginx2.tar
注意:导入后通过docker images 查看
docker import nginx-test.tar nginx:imp
或者
cat nginx-test.tar | docker import - nginx:imp
开启远程访问权限
vi /lib/systemd/system/docker.service
#修改ExecStart这行
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
#重新加载配置文件
# systemctl daemon-reload
#重启服务
# systemctl restart docker.service
#查看端口是否开启
# netstat -nlpt
#直接curl看是否生效
# curl http://127.0.0.1:2375/info
Linux系统检查端口是否开放
方法一
查看想开的端口是否已开:
firewall-cmd --query-port=2375/tcp
添加指定需要开放的端口:
firewall-cmd --add-port=2375/tcp --permanent
重载入添加的端口:
firewall-cmd --reload
查询指定端口是否开启成功:
firewall-cmd --query-port=123/tcp
移除指定端口:
firewall-cmd --permanent --remove-port=123/tcp
方法二
安装iptables-services :
yum install iptables-services
进入下面目录进行修改:
/etc/sysconfig/iptables

浙公网安备 33010602011771号