官方的nginx镜像由于我正在从nfs卷中挂载配置文件而无法启动。我正在尝试使用如下的bash脚本来解决这个问题,但是它并没有起作用。有什么建议吗?
kubectl logs conteinerxxx -p
返回nginx: invalid option: "off"
。但是nginx -g "daemon off;"
在我的shell上似乎运行良好。有更加惯用的方法吗?顺便说一下,这是DigitalOcean上的coreos集群。
Dockerfile
//REPLACE THE OLD `CMD ["nginx", "-g", "daemon off;"]`
ADD nginxinit.sh /nginxinit.sh
ENTRYPOINT ["./nginxinit.sh"]
bash
#!/usr/bin/env bash
until mountpoint -q /etc/nginx; do
echo "$(date) - wainting for NGINX config files to be mounted..."
sleep 1
done
nginx -g "daemon off;"
RC
apiVersion: v1
kind: ReplicationController
metadata:
name: mypod
labels:
name: mypod
spec:
replicas: 1
selector:
name: mypod
template:
metadata:
labels:
name: mypod
spec:
containers:
- image: cescoferraro/nginx
name: myfrontend
volumeMounts:
- mountPath: "/etc/nginx"
name: nginx-nfs
volumes:
- name: nginx-nfs
persistentVolumeClaim:
claimName: nginx-nfs
PV
apiVersion: v1
kind: PersistentVolume
metadata:
name: nginx-nfs
spec:
capacity:
storage: 32Mi
accessModes:
- ReadWriteMany
nfs:
# FIXME: use the right IP
server: x.x.x.x
path: "/nginx"
PVC
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: nginx-nfs
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 32Mi
echo "daemon off;" >> /etc/nginx/nginx.conf
? - AdelaN"docker cp containerxxx:/etc/nginx/* /tmp"
没有复制conf.d目录(我太蠢了)。所以我修复了它,并且我的镜像可以正常工作了。我以为它会在官方镜像中工作,但实际上并没有。使用nginx镜像似乎可以重现这个问题。 - CESCO