It's all about communication in docker.
123
In many application, you'll need more than one container - for two main reasons:
Multi-Container apps are quite common, especially if you're working on real applications.
Often, some of these Containers need to communicate though:
Here are the commands used in this project
For this, All the containers should be under the same network
docker network create network_name
docker network create mongo-net
docker network lsdocker network rm network_namedocker network --help is for help related to docker networkmongo image with volume and docker networkdocker run -d --rm -v mongo-com-vol:/data/db --name mongoCommunication --network mongo-net mongo:7.0
-v mongo-com-vol:/data/db is named volume with the name mongo-com-voldocker volume lsdocker volume rm volume_namedocker volume --help is for help related to docker volumedocker pull actionanand/docker_communication
docker run -d -p 3000:80 --rm --name docker_communication --network mongo-net actionanand/docker_communication
You can open the postman app(or any other similar client) and try the following API end points
GET request for http://localhost:3000/movies
GET request for http://localhost:3000/people
POST request for http://localhost:3000/favorites with the following body as example
{
"name": "A New Hope",
"type": "movie",
"url": "https://swapi.dev/api/films/1/"
}
And make sure to keep the type as either movie or character. If you use anything apart from this, error will be thrown from backend
GET request for http://localhost:3000/favorites
Content type
Image
Digest
sha256:b222e9b04…
Size
388.8 MB
Last updated
over 2 years ago
docker pull actionanand/docker_communication