【服务器部署】Docker环境的安装
基于CentOS系统的服务器环境下安装Docker环境,安装步骤参考官方指南:https://docs.docker.com/engine/install/centos/
配置库
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
安装Docker
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
启动Docker
sudo systemctl start docker
验证Docker
sudo docker run hello-world
删除Docker
如有需要,执行以下代码
sudo yum remove docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
Docker容器
redis
docker run --name redis -p 6379:6379 --restart=always -d redis
nginx
docker run --name nginx -p 80:80 -p 443:443 -v /opt/docker/nginx/html:/user/share/nginx/html -v /opt/docker/nginx/logs:/var/log/nginx -v /opt/docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /opt/docker/nginx/conf/conf.d:/etc/nginx/conf.d -d nginx
/opt/docker/nginx为自定义的本地目录,需要在执行命令前创建好。