Skip to content

felipevcc/docker-networking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker Networking

Simple example of Docker networking. Creating the environment manually and with Docker Compose.

This environment is composed of a Node.js application that depends on a Mongo database, each one in a different container connected through a network.

To configure it manually

Command to create the network:

docker network create --attachable appnet

To build the Node application image run the following command:

docker build -t mongoapp .

To run the containers from the images:

docker run -d --name db mongo
docker run -d --name app -p 3000:3000 --env MONGO_URL=mongodb://db:27017/test mongoapp

And finally, to connect the containers to the network previously created, execute each of these commands:

docker network connect appnet db
docker network connect appnet app

To configure it using Docker Compose

To build the services run the following command:

docker-compose build

Command to create and start the environment:

docker-compose up -d

Command to stop and delete the environment:

docker-compose down

For more information about Docker Compose consult its documentation

About

Docker networking and Docker Compose.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published