docker中如何部署nginx?本篇文章重点为大家讲解一下docker中部署nginx具体步骤,有需要的小伙伴可以参考一下。
环境
安装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
验证
以上就是良许教程网为各位朋友分享的Linu系统相关内容。想要了解更多Linux相关知识记得关注公众号“良许Linux”,或扫描下方二
维码进行关注,更多干货等着你 !