Hi everyone! I have an Ubuntu 14 machine with Nginx and Docker… Nginx is set to listen to localhost:80 and forwarding requests to Docker’s network, where is running a container with a second Nginx and a Laravel App.
if i use the default docker bridge network, i always get problem with communications between nginx on ubuntu machine and the container into docker’s network. When i try to set up the “host_binding_ipv4” parameter i get this error back: “error response from Deamon: driver failed programming external connectivity on endpoint. Error starting userland proxy: listen tcp 0.0.0.0:80” note that i want to modify that 0.0.0.0 ip in something like 173.17.0.1 but unsuccessfully. How can i forward the requests to the docker container?
Now i’m trying to use a docker-compose configuration like seguent:
version: '2'
services:
service_laravel:
container_name: service_laravel
restart: always
build:
context: .
dockerfile: Dockerfile
networks:
docker1:
ipv4_address: 173.17.0.2
ports:
- 8000:80
networks:
docker1:
driver: bridge
ipam:
driver: default
config:
- subnet: 173.17.0.0/16
gateway: 173.17.0.1
…with this nginx configuration…
#Ubuntu Nginx
server {
listen 80;
server_name localhost;
# Proxying the connections
location / {
proxy_pass http://173.17.0.1:8000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
}
…i have a Dockerfile that build the container with laravel and Nginx… but i get this error when i run “docker-compose up”
ERROR: yaml.parser.ParserError: while parsing a block collection
in "./docker-compose.yml", line 23, column 13
expected <block end>, but found '?'
in "./docker-compose.yml", line 24, column 13
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Yaml weirdness, but try aligning your subnet and gateway tags:
version: '2'
services:
service_laravel:
container_name: service_laravel
restart: always
build:
context: .
dockerfile: Dockerfile
networks:
docker1:
ipv4_address: 173.17.0.2
ports:
- 8000:80
networks:
docker1:
driver: bridge
ipam:
driver: default
config:
- subnet: 173.17.0.0/16
gateway: 173.17.0.1
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.