2.软文推荐
3.软文推荐
docker中如何部署nginx?本篇文章重点为大家讲解一下docker中部署nginx具体步骤,有需要的小伙伴可以参考一下。
环境centos7
安装docker 移除旧版本docker[root@chaols ~]# sudo yum remove docker
> docker-client
> docker-client-latest
> docker-common
> docker-latest
> docker-latest-logrotate
> docker-logrotate
> docker-engine
安装yum-utils包并设置稳定存储库
[root@chaols ~]# yum install -y yum-utils
安装docker
[root@chaols ~]# yum install docker-ce docker-ce-cli containerd.io
启动docker
[root@chaols ~]# systemctl start docker
查看docker镜像
刚刚安装docker是没有镜像的
[root@chaols ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
部署nginx
下载nginx镜像
[root@chaols ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
e1acddbe380c: Pull complete
e21006f71c6f: Pull complete
f3341cc17e58: Pull complete
2a53fa598ee2: Pull complete
12455f71a9b5: Pull complete
b86f2ba62d17: Pull complete
Digest: sha256:4d4d96ac750af48c6a551d757c1cbfc071692309b491b70b2b8976e102dd3fef
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
创建nginx虚拟机
run 运行 -it 交互模式 –name 指定名字 -p 宿主机:docker虚拟机 nginx 镜像名字 /bin/bash 启动容器后启动bash
[root@chaols ~]# docker run -it --name chao.nginx -p 8080:80 nginx /bin/bash
root@8ebe4de10f2c:/# /etc/init.d/nginx start
2021/08/21 07:58:49 [notice] 11#11: using the "epoll" event method
2021/08/21 07:58:49 [notice] 11#11: nginx/1.21.1
2021/08/21 07:58:49 [notice] 11#11: built by gcc 8.3.0 (Debian 8.3.0-6)
2021/08/21 07:58:49 [notice] 11#11: OS: Linux 3.10.0-1160.el7.x86_64
2021/08/21 07:58:49 [notice] 11#11: getrlimit(RLIMIT_NOFILE): 1048576:1048576
root@8ebe4de10f2c:/# 2021/08/21 07:58:49 [notice] 12#12: start worker processes
2021/08/21 07:58:49 [notice] 12#12: start worker process 13
验证
本文来源:www.lxlinux.net/6895.html,若引用不当,请联系修改。
1
合优网络成立至今已有14年,一直秉承着"诚信、责任、团队、敬业"的服务宗旨,成立至今获得了5万多家企业的认同并建立起长期合作的伙伴...