建个网站公司,网站建设推广咨询平台,长春网站建设公司,国内搜索引擎排名2022背景描述
项目需要在研发环境虚拟机上安装docker部署应用。
所在的服务器是一个内网#xff0c;无法访问到外网环境。
服务器OS版本是 麒麟V10 linux
安装docker
安装包下载
获取所需版本的docker binary包#xff0c;官方链接https://download.docker.com/linux/stati…
背景描述
项目需要在研发环境虚拟机上安装docker部署应用。
所在的服务器是一个内网无法访问到外网环境。
服务器OS版本是 麒麟V10 linux
安装docker
安装包下载
获取所需版本的docker binary包官方链接https://download.docker.com/linux/static/stable/x86_64/.
我下载的是docker-26.1.4.tgz版本
解压压缩包并把文件放在/usr/bin/
tar -zxvf docker-26.1.4.tgz
sudo cp docker/* /usr/bin/ 新增用户组 docker。其他用户需要有docker的执行权限只需将用户加入docker用户组即可
$ sudo groupadd docker
$ sudo usermod -aG docker $USER编写docker.service文件放到目录/etc/systemd/system
[Unit]
DescriptionDocker Application Container Engine
Documentationhttps://docs.docker.com
Afternetwork-online.target firewalld.service
Wantsnetwork-online.target
[Service]
Typenotify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart/usr/bin/dockerd
ExecReload/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILEinfinity
LimitNPROCinfinity
LimitCOREinfinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMaxinfinity
TimeoutStartSec0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegateyes
# kill only the docker process, not all processes in the cgroup
KillModeprocess
# restart the docker process if it exits prematurely
Restarton-failure
StartLimitBurst3
StartLimitInterval60s
[Install]
WantedBymulti-user.target
启动docker service,并设置开机自启动
$ sudo chmod x /etc/systemd/system/docker.service
$ sudo systemctl daemon-reload
$ sudo systemctl start docker
$ sudo systemctl enable docker验证 sudo systemctl status docker 使用docker ps命令报错
[appadminiomapp ~]$ docker ps
permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.45/containers/json: dial unix /var/run/docker.sock: connect: permission denied
检查是否将用户加入docker用户组并且需要重新登录用户才能生效。 保存镜像进行打包在另一台服务上使用
docker save -o nginx_latestx86.tar nginx:lastest
在另一台服务器上docker加载tar包
docker load -i nginx_latestx86.tar 测试启动nginx镜像但是启动后访问nginx无反应参考 Docker解决宿主机无法访问docker容器中nginx服务-CSDN博客