龙空技术网

k8s第7天-CMD/ENTRYPOINT

热心市民jkl 125

前言:

此刻兄弟们对“nginx打开localhost”大体比较关怀,大家都想要学习一些“nginx打开localhost”的相关知识。那么小编在网络上网罗了一些关于“nginx打开localhost””的相关资讯,希望朋友们能喜欢,看官们一起来学习一下吧!

配置yum 阿里源

1.备份原来的yum文件mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak2.下载阿里云yum配置到 /etc/yum.repos.d/wget -O /etc/yum.repos.d/CentOS-Base.repo .跟新yum makecacheyum -y update
CMD/ENTRYPOINT指令

cmd和entrypoint指令的作用相同,使用方法略又不同

CMD指令

- Dockerfilevim /data/dockerfile/DockerfileFROM centos:7RUN yum install httpd -yCMD ["httpd", "-D", "FOREGROUND"]制作镜像docker build . -t kaili/httpd:test运行容器测试docker run -d --rm --name myhttpd -p83:80 kaili/httpd:test
ENTRYPOINT指令Dockerfile
vim /data/dockerfile/DockerfileFROM centos:7ADD entrypoint.sh /entrypoint.shRUN yum install epel-release -q -y && yum install nginx -yENTRYPOINT /entrypoint.sh
配置entrypoint.sh脚本

vim /data/dockerfile/entrypoint.sh

#!/bin/bash/sbin/nginx -g "daemon off;"chmod +x entrypoint.sh
制作镜像
docker build . -t kaili/nginx:mynginxdocker run --rm kaili/nginx:mynginx docker exec -it compassionate_solomon /bin/bash
问题warning: /var/cache/yum/x86_64/7/docker-ce-stable/pa...解决办法

安装的过程遇到这些问题

warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/containerd.io-1.3.7-3.1.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY

Public key for containerd.io-1.3.7-3.1.el7.x86_64.rpm is not installed

需要关闭docker-ce的gpg验证,将gpgcheck=1改成gpgcheck=1=0步骤如下

vim /etc/yum.repos.d/docker-ce.repo

%s/gpgcheck=1/gpgcheck=0/g(全局替换脚本)

插曲

docker run --rm kaili/nginx:mynginx使用ctrl+C 杀不掉[root@localhost dockerfile]# docker ps -a | grep nginx7e7ab6cd5b57   kaili/nginx:mynginx   "/bin/sh -c /entrypo…"   About a minute ago   Up About a minute                                             charming_borgdocker rm -f 7e7ab6cd5b57
启动容器测试
docker run --rm -p84:80 kaili/nginx:mynginx[root@localhost dockerfile]# docker ps -a | grep nginxc3b5fba77d10   kaili/nginx:mynginx   "/bin/sh -c /entrypo…"   About a minute ago   Up About a minute         0.0.0.0:84->80/tcp, :::84->80/tcp   upbeat_cray[root@localhost dockerfile]# docker exec -it upbeat_cray /bin/bash[root@c3b5fba77d10 /]# cat /entrypoint.sh#!/bin/bash/sbin/nginx -g "daemon off;"[root@c3b5fba77d10 /]#

标签: #nginx打开localhost