Ranter
Join devRant
Do all the things like
				++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
				Sign Up
			Pipeless API
 
				From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
				Learn More
			Comments
		
- 
				
				 tyler1338196y@alexbrooklyn my php docker container using an .env file wont connect to my mongodb in another environment. Im thinking cause its binded to 0.0.0.0 i should bind it to 127.0.0.1 in the docker compose. Any suggestions? tyler1338196y@alexbrooklyn my php docker container using an .env file wont connect to my mongodb in another environment. Im thinking cause its binded to 0.0.0.0 i should bind it to 127.0.0.1 in the docker compose. Any suggestions?
- 
				
				@tyler1338 First thing I'd do is throw out the .env file and switch to environment variables
 
 But you both run them in docker-compose right? Are they both connected in a network? Does the mongodb have an open port with expose ?
 
 What address do you use in the php container to connect to the mongodb container?
- 
				
				 tyler1338196y@alexbrooklyn i can connect to the container using localhost from my machine but when it comes to the other container connecting it doesnt work. tyler1338196y@alexbrooklyn i can connect to the container using localhost from my machine but when it comes to the other container connecting it doesnt work.
- 
				
				@tyler1338 Yep, that makes perfect sense.
 
 You see, a container has its own network, so using 'localhost' inside a container will point to the same container, so itself.
 
 Docker and docker-compoes have a great way of connecting containers and that is using the service name of the container you want to connect to.
 
 For example:
 ---------------------------
 networks:
 database: ~
 
 services:
 mongodb:
 image: ...
 network:
 - database
 [...]
 
 php:
 image ...
 network:
 - database
 [...]
 
 -----------------------
 
 Then you can replace 'localhost' in your php container with 'mongodb'.
 
 Also, I really advice to delete the .env file, it makes your container inflexible, opposed to environment variables that allow you to configure stuff from the outside.
Related Rants
- 
						
							 vane11CEO hired graphics designer without HR help after first meeting and that person first day of his work borrowed... vane11CEO hired graphics designer without HR help after first meeting and that person first day of his work borrowed...
- 
						
							 nachocode10Is this the code life Another scrum meeting Caught in the the Node life No escape from reality Open your eyes ... nachocode10Is this the code life Another scrum meeting Caught in the the Node life No escape from reality Open your eyes ...
- 
						
							 tahnik7Our scrum master is called ScrumBag in our department xD tahnik7Our scrum master is called ScrumBag in our department xD




Boss: here you go 3 tasks for your sprint
Days later with local server and db still not connecting on docker.
Boss: ya can we add a task on jira and get that fixed as soon as possible and see why its not working(feature doesnt work)
Me: you got it boss.
Me(in head): How am i ever going to finish my sprint for next Friday...
rant
wk173
scrum
sprint