I am tring to use docker because I will need it at work for laravel, and I am trying to get used to it. I created the dockerfile and pasted this from a tutorial that I found online:
FROM php:5.6.30-fpm-alpine
RUN apk update && apk add build-base
RUN apk add postgresql postgresql-dev \
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
&& docker-php-ext-install pdo pdo_pgsql pgsql
RUN apk add zlib-dev git zip \
&& docker-php-ext-install zip
RUN curl -sS https://getcomposer.org/installer | php \
&& mv composer.phar /usr/local/bin/ \
&& ln -s /usr/local/bin/composer.phar /usr/local/bin/composer
COPY . /app
WORKDIR /app
RUN composer install --prefer-source --no-interaction
ENV PATH="~/.composer/vendor/bin:./vendor/bin:${PATH}"
I created the docker-compose.yml file and pasted this:
version: '2'
services:
nginx:
image: nginx:1.11.10-alpine
ports:
- 3000:80
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
web:
build: .
ports:
- 9000:9000
volumes:
- .:/app
- /app/vendor
depends_on:
- postgres
environment:
DATABASE_URL: postgres://todoapp@postgres/todos
postgres:
image: postgres:9.6.2-alpine
environment:
POSTGRES_USER: todoapp
POSTGRES_DB: todos
I do docker-compose up-d
and it seems to be working, but if I try to do docker-compose ps
I don'thave any ports on row one, and on state I have Exit 1
When I try to go to localhost:3000/todos
it says that the page is not found. If i try to do curl localhost:3000/todos
it says that the connection is refused.... What do I do?
EDIT:
./nginx.conf:
server {
listen 80;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /app/public/;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ ^/.+\.php(/|$) {
fastcgi_pass web:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
text:
nginx_1 | 2019/02/13 14:30:19 [emerg] 1#1: host not found in upstream "web" in /etc/nginx/conf.d/default.conf:12
nginx_1 | nginx: [emerg] host not found in upstream "web" in /etc/nginx/conf.d/default.conf:12