我需要让 3 项服务仅在一个 docker 容器中运行。我在一个 docker-compose 中完成了这个“系统”,但由于一些限制,我只需要将它放入一个 dockerfile 中。我要运行的应用程序是 PHP(使用 Symfony)+ MongoDb。
现在,我正在执行这个命令:
sudo docker run -p 9091:80 -p 27017:27017 myapp
当我浏览到 localhost:9091 时,我得到的最大值是 502 错误。
谢谢
Dockerfile:
FROM php:7.3-fpm-stretch
COPY --from=composer /usr/bin/composer /usr/bin/composer
RUN apt update
RUN apt install -y \
nginx \
mongodb
COPY nginx.conf /etc/nginx/nginx.conf
RUN pecl install mongodb
RUN docker-php-ext-enable mongodb
RUN service nginx start
RUN service mongodb start
EXPOSE 9091
EXPOSE 27017
COPY entrypoint.sh /
WORKDIR /usr/www
ENTRYPOINT ["/entrypoint.sh"]
COPY . /usr/www
入口点.sh
#!/bin/bash
set -e -u
service nginx start
service mongodb start
tail -f /dev/null
nginx.conf
events {
worker_connections 1024;
}
http {
server {
listen 80;
server_name localhost;
root /usr/www/public;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ ^/index\.php(/|$) {
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
error_log /dev/stderr debug;
access_log /dev/stdout;
}
}
繁星点点滴滴
烙印99