我想将服务器部署到AWS EC2实例。当我在ssh控制台中输入“sudo docker-compose up”时,出现以下错误:
ERROR: for nginx Cannot start service nginx: OCI runtime create failed: container_linux.go:345: starting container process caused "process_linux.go:430: container init caused \"rootfs_linux.go:58: mounting \\"/home/ubuntu/site/nginx/default.conf\\" to rootfs \\"/var/lib/docker/overlay2/b24f64910c6ab7727a4cb08afac0d034bb759baa4bfd605466ca760359f411c2/merged\\" at \\"/var/lib/docker/overlay2/b24f64910c6ab7727a4cb08afac0d034bb759baa4bfd605466ca760359f411c2/merged/etc/nginx/conf.d/default.conf\\" caused \\"not a directory\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
这是我的docker-compose.yml文件:
version: '2'
networks:
SRVR:
services:
nginx:
image: nginx:stable-alpine
container_name: SRVR_nginx
ports:
- "8080:80"
volumes:
- ./code:/code
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
- ./nginx/logs:/var/log/nginx
depends_on:
- php
networks:
- SRVR
php:
build: ./php
container_name: SRVR_php
volumes:
- ./code:/code
ports:
- "9000:9000"
networks:
- SRVR
相同的docker-compose.yml在运行Ubuntu OS的本地计算机上运行良好。 EC2实例还运行Ubuntu OS。
最佳答案
您的问题是./nginx/default.conf
。 docker会将其识别为文件夹,并且您将/etc/nginx/conf.d/default.conf
作为文件。
关于amazon-web-services - 尝试在AWS上启动时docker-compose返回错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58474949/