This repository is part of a group of repositories called Devops-Journey*. It contains the files of a react application that says "Hello" to anyone.
Using docker-compose
with images can be slightly tricky as compared to simply using a docker run
.
Always use a docker-compose down
to remove any containers created by compose
.
Enabling authentication with a mongodb image is a tad complicated however these are the steps I took to successfully enable authentication.
docker-compose up
Go into the mongodb container, 'k8sdb' in this case using the following command
docker exec -it k8sdb /bin/bash
Now create the database of your choice and add a user using the mongo-cli. Assign the user some roles if you will, using the roles array.
>>> mongo
>>> use names
>>> db.createUser({user: 'username', pwd: 'password', roles: []})
mongoose.connect('mongodb://mongo:27017/names',{
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false,
useCreateIndex: true,
user: 'username',
pass: 'password'
}).then(() => console.log('Successfully connected to names DB))
.catch(err => console.log("Error connecting to names Db"))
It is easier to start a mongodb container without authentication and implement some authentication after building the project with docker compose
.
- Environment variables
- Networks
- Pushing to a container repository like dockerhub.
Practice k8s locally using minikube and then successfully create deployments on kubernetes clusters in the cloud using DigitalOcean or Linode.
- Download the docker-compose.yml file and simply run
docker-compose up
Make sure you're in the directory that contains the docker-compose.yml file.
- All codes can be found in the DevOps-Journey-* repositories.