Docker手动安装与换源
·
如何在Ubuntu上开启SSH服务 并开机启动_ubuntu ssh 开机启动-CSDN博客
ubuntu20.04 安装docker (详细版)【24】_docker ubuntu image-CSDN博客
文章目录
Docker手动安装与换源
手动安装
wget https://download.docker.com/linux/static/stable/x86_64/docker-24.0.0.tgz
tar -zxvf docker-24.0.0.tgz
cp docker/* /usr/bin/
vim /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 -H unix:///var/run/docker.sock --selinux-enabled=false --default-ulimit nofile=65536:65536
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 u+x /etc/systemd/system/docker.service
systemctl daemon-reload
systemctl start docker
换源
root@ubuntu:/data/Docker/nginx#
cat /etc/docker/daemon.json
{
"registry-mirrors":[
"https://docker.1ms.run",
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn",
"https://registry.docker-cn.com"
]
}
#重新加载配置
systemctl reload docker
#重启docker服务
systemctl restart docker
#拉取镜像
docker pull nginx
#运行容器,部署Nginx服务
root@ubuntu:/data/Docker/nginx# cat run.sh
#!/bin/bash
CONTAINER_NAME="my-nginx"
HOST_PORT=8080
CONTAINER_PORT=80
HOST_CONF="/data/Docker/nginx/nginx.conf"
CONTAINER_CONF="/etc/nginx/nginx.conf"
#运行
docker run -d\
--name $CONTAINER_NAME\
-p $HOST_PORT:$CONTAINER_PORT\
-v $HOST_CONF:$CONTAINER_CONF\
nginx:latest
echo "Nginx running..."
更多推荐



所有评论(0)