-
Notifications
You must be signed in to change notification settings - Fork 0
docker 离线使用
zeze.li edited this page May 19, 2021
·
1 revision
官网下载离线安装包
$ tar -xvf docker-19.03.6.tar
$ cp docker/* /usr/bin/ # 复制到该目录
在/etc/systemd/system
下创建docker.service
服务,并配置以下内容保存
[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
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.
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
chmod +x /etc/systemd/system/docker.service
systemctl daemon-reload
systemctl start docker
systemctl enable docker.service
systemctl status docker
docker -v
报错的原因是因为手动安装的没有将docker
配置到系统环境变量中
$ vim /etc/profile
# 写入以下内容 export PATH=$PATH:/usr/bin/docker/
$ source /etc/profile #使配置生效
$ docker commit container__id mynewimage
$ docker save mynewimage > /tmp/mynewimage.tar
$ docker load < /tmp/mynewimage.tar
$ docker run --privileged=true --restart always -itd --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -v /opt/docker_v/mysql/data:/var/lib/mysql mysql
$ docker run -itd --name redis-test -p 6379:6379 redis
docker inspect container_name | grep Mounts -A 20
自定义边栏是什么东西