[Docker] Offline installation, ordinary users execute docker commands, image archives and tar packages, and loads tar package images

Offline installation

1. Download the official offline package of docker.
First download the offline package in an environment with external network.
The official address of the installation package: https://download.docker.com/linux/static/stable/x86_64/

2. Upload the offline package to the server.
Use the scp command or ftp tool to upload the downloaded offline package to the designated server.

3. Offline package decompression
tar -zxvf docker-20.10.8.tgz

4. Copy the decompressed file to /usr/bin/
sudo cp docker/* /usr/bin/

5. Register docker as service.
Add the docker.service file in the /etc/systemd/system/ directory.
sudo vi /etc/systemd/system/docker.service
input content

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
  
[Service]
Type=notify
# 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
# 如果有搭建私有镜像仓库,--insecure-registry设置为私有镜像仓库地址。
ExecStart=/usr/bin/dockerd --selinux-enabled=false --insecure-registry=127.0.0.1
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.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
  
[Install]
WantedBy=multi-user.target

6. Start the docker service
and grant execution permission to docker.service
chmod +x /etc/systemd/system/docker.service

Reload the configuration file to take effect
systemctl daemon-reload

Start
sudo systemctl start docker

Set the service to start automatically at boot
sudo systemctl enable docker.service

View service status
systemctl status docker

Ordinary users execute the dockers command

method one:


用户组配置文件:/ect/group 即用户组的所有信息都存放在此文件中。

新建用户组 docker,如果用户组已经存在则跳过

sudo groupadd docker

将 appuser用户添加到 docker 组

gpasswd -a appuser docker

刷新 docker 组

newgrp docker		

方法二:
解决办法就是修改 /var/run/docker.sock 文件的权限,让普通用户也可以访问。

修改文件权限
sudo chmod 666 /var/run/docker.sock

Image archive, tar package, and load tar package image

Image packaging
docker save Image name: Image version > packaged file name.tar
Insert image description here
Load the image into the docker system
docker load -i packaged file name.tar
Insert image description here

Guess you like

Origin blog.csdn.net/qq_44961149/article/details/125280224