6/19/2023 0 Comments Docker mongodb![]() ![]() Set the username and password of the Database. This option make it easy for us! Check your ip address with ifconfig in Linux and REPLACE "(YOUR MACHINE/SERVER IP)" extra_hosts : - " localhost:(YOUR MACHINE/SERVER IP)" # mongo images use this variables inside the container and they are very helpful. Since it is mapped inside the container we don't need to copy any files (nice and slender!) entrypoint : # setting the inside network networks : # the name of the below configured network we have to belong to it my_network : # we have to specify a FIXED IP - this IP will be use after ipv4_address : 170.17.5.5 # This works like MAGIC - this allows us to connect inside the network "my_network" FROM THE HOST - because we are creating a closed network we would have to configure a DNS server only to reach it. Note that the nf is inside the volume folder set in the volume section. So basically we are saying run mongo database with this file configuration settings. keep it alive! restart : always # entrypoint will execute a command inside the container as soon as it starts. Since we have 3 nodes we need three places which will hold information this is the first one - /path/to/your/OS/folder/data/node_1:/data/db # This volume will hold the Server Certificate file which will be signed by the CA and will make work TLS - The shell script create all the folders inside ssl just need to run the script! - /path/to/your/OS/folder/ssl/node_1:/data/ssl # This volume will hold this node cluster configuration! Each node has it's own configuration and differences, but to simplify things I just created ONE configuration to dominate them ALL =D! The file is the nf - /path/to/your/OS/folder/config:/data/config # always restart right. # docker-compose yml file # docker version must be compatible with your running docker version # for more info see # Don't forget to use only spaces to indent ok! version : " 3.9" services : # The container mongo_node_1 configurations # mongo_node_1 : container_name : mongo_node_1 hostname : mongo_node_1 # the image from the docker-hub repository image : " mongo" # mongo uses port 27017 to change see more info expose : - " 27017" # here comes the interesting part, with volumes we can easily insert all the configuration that we need! volumes : # This volume will hold the database information, what you save, your collections, documents, etc. So we have to create the following docker-compose file, all the explanation is in its comments section by section: well you need to start studying because your path is long my friend.įirst things first, an image to help us visualize the configuration settings of what we will be accomplishing. If you didn’t understand anything from the last phrase above. Plus you can grab and customize it at your will and risk. In the next lines I will deliver a shell script to create ALL the certificates, CA, Server and Client to connect, as the docker compose file. I intend to explain how I did configure a MongoDB ReplicaSet with 3 nodes in Docker Containers. ![]() In my belief who works with code, programming, configuring servers, databases, front-ends, back-ends are the today’s magicians of a RPG game.Īnyway, let’s start talking about the important stuff. Since new technologies up to new business rules. The development is a difficult area, specially because we have to know everything, literally. This is my very first article! I am excited about it. ![]() And yes… All easy with shell scripts (Linux) and ready to run! )! ![]()
0 Comments
Leave a Reply. |