I try to run nginx service in docker-compose, and get this error.
My docker-compose file
version: '3.7'
services:
nginx:
image: nginx:alpine
container_name: nginx
ports:
- 80:80
volumes:
- ./apps/:/apps
- ./services/nginx/conf.d/:/etc/nginx/conf.d/
depends_on:
- php73
- php80
restart: always
networks:
mp-network:
ipv4_address: 192.168.220.10
...
It worked before it... I don't have local nginx or apache2 (port 80 free), and i tried to change port in docker-compose file - result the same.
Help please.
I solved this problem. The reason was in ipv4_address: 192.168.220.10 - I had 10 services in ipv4_address: 192.168.220.* ips, and 11th was nginx with hard defined ip, wich was busy
Related
I have configured the drupal docker container along with the webserver using below-mentioned steps on rhel 8 server using podman docker.
My docker-compose file:
version: "3"
services:
drupal:
image: drupal:9.2.7-php8.0-fpm-alpine
container_name: drupal
restart: unless-stopped
networks:
- internal
- external
webserver:
image: nginx:1.21.3
container_name: webserver
depends_on:
- drupal
restart: unless-stopped
ports:
- 80:80
- 443:443
volumes:
- ./drupal-data:/var/www/html
- ./nginx-conf:/etc/nginx/conf.d
networks:
- external
networks:
external:
driver: bridge
internal:
driver: bridge
volumes:
drupal-data:
db-data:
If I enter commands manually on the server end, I get the correct response properly but Can't get any response from the browser.
As below response getting from server end,
Could you please suggest the solution for this issue why didn't get any response on the browser, and how to fix this issue?
This is necessary as Traefik doesn't support php-fpm.
This docker-compose.yml doesn't work:
version: '3'
services:
#php
...
#Nginx Service
webserver:
image: nginx:alpine
container_name: webserver
restart: unless-stopped
tty: true
volumes:
- ./:/var/www
- ./nginx/conf.d/:/etc/nginx/conf.d/
networks:
- app-network
- traefik
labels:
- traefik.http.routers.webserver.rule=Host(`nginx.your_domain`)
- traefik.http.routers.webserver.tls=true
- traefik.http.routers.webserver.tls.certresolver=lets-encrypt
- traefik.port=80
#Docker Networks
networks:
app-network:
driver: bridge
traefik:
external: true
However, if I make an innocuous edit like change the version number to 3.7 (or change back to 3, from 3.7) it suddenly works, but isn't consistent.
How do I successfully route Traefik to an Nginx container?
#1. Docker compose file version is related to the engine, so please make sure you match that:
https://docs.docker.com/compose/compose-file/
#2. You could try to run the basic example from Traefik:
https://doc.traefik.io/traefik/user-guides/docker-compose/basic-example/
I'm assuming this is traefik latest (2.4)
I'm little bit confused with docker and network communication. I tried many things but it didn't work :-(.
I have following docker compose:
version: '3'
services:
nginx:
container_name: nginx
image: nginx:stable-alpine
restart: unless-stopped
tty: true
ports:
- 80:80
volumes:
- ./nginx/conf.d:/etc/nginx/conf.d:ro
depends_on:
- app
networks:
- frontend
- backend
app:
restart: unless-stopped
tty: true
build:
context: .
dockerfile: Dockerfile
container_name: app
expose:
- "9090"
ports:
- 9090:9090
networks:
- backend
networks:
frontend:
backend:
And I would like to communicate:
From nginx to app //this probably works
From app to postgreSQL which is installed on server (no docker container)
I cannot do this, I tried many things but something is wrong :-(
You can choose any of these two options:
Make your postgresql listen to all your network interfaces (or the docker bridge for more secure but complex setup), to achieve that you need to make sure your config looks like this:
# grep listen /var/lib/pgsql/data/postgresql.conf
listen_addresses = '*'
Use host network mode in your docker compose, which runs docker in your host network name space instead of creating a new network:
network_mode: "host"
Firstly thank you for your time .
i was trying my hands on docker.
when i saw this article
http://jasonwilder.com/blog/2014/03/25/automated-nginx-reverse-proxy-for-docker/
please have a look at my docker-compose.yml file , i am using below images
jwilder/nginx-proxy:latest
grafana/grafana:4.6.2
version: "2"
services:
proxy:
build: ./proxy
container_name: proxy
restart: always
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/tmp/docker.sock:ro
ports:
- 80:80
- 443:443
grafana:
build: ./grafana
container_name: grafana
volumes:
- grafana-data:/var/lib/grafana
environment:
VIRTUAL_HOST: grafana.localhost
GF_SECURITY_ADMIN_PASSWORD: password
depends_on:
- proxy
volumes:
grafana-data:
so when i do docker-compose up -d on my local system i am able to access the grafana container.
Now i have deploy this docker app on aws how do i access the grafana container on ec2 with VIRTUAL_HOST
any help or idea how to do this will be appreciated ! Thanks !
Looking to automatically add the nginx container ip address inside my phpfpm container /etc/hosts file.
Inside my yml file, I have a service called phpfpm, and I know you can use extra_hosts attribute to assign values into the /etc/hosts file, however I don't know how to dynamically call place the nginx container IP.
nginx:
build: ./nginx
ports:
- "80:80"
- "443:443"
volumes:
- ../public/:/var/www/html/public/
container_name: nginx
networks:
- backend
phpfpm:
build: ./php-fpm
volumes:
- ../public/:/var/www/html/public/
container_name: phpfpm
extra_hosts:
- "test.local:nginx" <insert nginx ip to test.local>
networks:
- backend
Any thoughts on how to do this?
Containers within a compose file will run on same network and you can just their names. phpfpm and nginx in your case. Also if you need more names for the same service you need to use aliases
nginx:
build: ./nginx
ports:
- "80:80"
- "443:443"
volumes:
- ../public/:/var/www/html/public/
container_name: nginx
networks:
backend:
aliases:
- test.local
phpfpm:
build: ./php-fpm
volumes:
- ../public/:/var/www/html/public/
container_name: phpfpm
networks:
- backend
Why do you need Nginx Ip address? You can call nginx from phpfpm container by hostname nginx