I'm creating a mongo container using this command
docker run -d -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=password --net mongo-network --name mongodb mongo
, then executing this command to see its logs docker logs mangodb
i'm getting this reult
i cant understand if mongodb is successfully created or not
Related
I am trying to carry out some experiments with Docker, MongoDB, and mongo-express.
Here was what I did:
docker network create my-network
docker run -d -p 27017:27017 --network my-network --name my-mongo -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=pass mongo
docker run -d -p 8081:8081 --network my-network --name my-mongo-express -e ME_CONFIG_OPTIONS_EDITORTHEME="ambiance" -e ME_CONFIG_MONGODB_SERVER="my-mongo" -e ME_CONFIG_BASICAUTH_USERNAME="admin" -e ME_CONFIG_BASICAUTH_PASSWORD="pass" mongo-express
No error message was received apparently.
However, when I entered the address "localhost:8081" on Chrome, the page displayed an error message saying:
This page isn’t working
localhost didn’t send any data.
ERR_EMPTY_RESPONSE
How can I fix this?
You set the admin username and password on the database, but then you use the 'normal' user environment variables to try to log on. Instead of ME_CONFIG_BASICAUTH_USERNAME and ME_CONFIG_BASICAUTH_PASSWORD, you should use ME_CONFIG_MONGODB_ADMINUSERNAME and ME_CONFIG_MONGODB_ADMINPASSWORD, like this
docker run -d -p 8081:8081 --network my-network --name my-mongo-express -e ME_CONFIG_OPTIONS_EDITORTHEME="ambiance" -e ME_CONFIG_MONGODB_SERVER="my-mongo" -e ME_CONFIG_MONGODB_ADMINUSERNAME="admin" -e ME_CONFIG_MONGODB_ADMINPASSWORD="pass" mongo-express
After pulling run this commands
"docker run -d -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=password --name mongodb --net mongo-network mongo "
for mongodb and this
"docker run -d -p 8081:8081 -e ME_CONFIG_MONGODB_ADMINUSERNAME=admin -e ME_CONFIG_MONGODB_ADMINPASSWORD=password --net mongo-network --name mongo-express -e ME_CONFIG_MONGODB_SERVER=mongodb mongo-express"
for mongo express after opening the port in my localhost:8081 on server side it is showing that "Turn on admin in config.js to view server stats!" i'm kind of stuck here
Had the same problem. So i went and checked mongo-express-docker Github issue page. Someone raised a question there.
Apparently, mongo-express in docker latest release is 1.0.0-alpha, doesn't have server status, but 0.54.0 had it.
Try: docker pull mongo-express:0.54.0
And then remember to use mongo-express:0.54.0 for whatever you're doing later.
I tried adding a tag --restart always. It's working fine for me.
docker network create mongo-network
docker run -d -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=password --name mongodb --net mongo-network --restart always mongo
docker run -d -p 8081:8081 -e ME_CONFIG_MONGODB_ADMINUSERNAME=admin -e ME_CONFIG_MONGODB_ADMINPASSWORD=password --net mongo-network --name mongo-express -e ME_CONFIG_MONGODB_SERVER=mongodb --restart always mongo-express
I launch a container running PostgreSQL with the command:
docker run -p 5432:5432 -d -it -e POSTGRES_USER='postgres' -e POSTGRES_PASSWORD='postgres' -e POSTGRES_DB='thingsboard' --name postgres postgres
Then, I launch ThingsBoard providing some environment variables to use the PostgreSQL database:
docker run -it -p 9090:9090 -p 1883:1883 -p 5683:5683/udp -v ~/.mytb-data:/data -v ~/.mytb-logs:/var/logs/thingsboard --name thingsboard --restart always -e SPRING_DATASOURCE_URL=jdbc:postgresql://<MY_LOCAL_IP>:5432/thingsboard -e SPRING_DATASOURCE_USERNAME=postgres -e SPRING_DATASOURCE_PASSWORD=postgres thingsboard/tb-postgres
where <MY_LOCAL_IP> is my IP address on the local network. I checked PostgreSQL, which actually binds to <MY_LOCAL_IP>:5432 (verified through PGAdmin).
The thingsboard container returns an error:
I expect ThingsBoard itself to create the tables in the thingsboard database, but it seems that it doesn't appen so. Any guess on the possible cause of this error? Thanks.
It seems that the problem is given by the volumes: mytb-data and mytb-logs have been created before and are not empty. The containers work as long as we launch thingsboard with:
docker run -it -p 9090:9090 -p 1883:1883 -p 5683:5683/udp --name thingsboard --restart always -e SPRING_DATASOURCE_URL=jdbc:postgresql://<MY_LOCAL_IP>:5432/thingsboard -e SPRING_DATASOURCE_USERNAME=postgres -e SPRING_DATASOURCE_PASSWORD=postgres thingsboard/tb-postgres
I am trying to connect Odoo to a Postgres database instance which is running in Docker, but having trouble figuring out how to connect them. I created my instance like so:
$ docker run -d -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo -e POSTGRES_DB=postgres --name mydb postgres:10
Only Postgres is running in Docker, not Odoo. How would I connect the Postgres running inside Docker to the outside Odoo?
Shortly:
You have to open the port of your docker instance
-p 5432:5432
Example:
docker run -d -p 5432:5432 -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo -e POSTGRES_DB=postgres --name mydb postgres:10
Description
Because when you run a container with docker, it is not exposed by default to the host network. So when you run Postgres, it is not accessible outside of the container. In order to make it accessible, you could :
Export a specific port : docker run -d -p 5432:5432 ...
Use the host network: docker run --network=host ...
Bonus:
If you wish to run odoo within a container in the future, you might need to create a docker network docker network create odooNetwork and use it for your Postgres and Odoo instances :
docker run -d --network=odooNetwork ...
More details about docker network in the documentation
I'm running an ubuntu 16.04 LTS server with some docker container. One of these containers is a mongoDB container, where my data is stored.
Now I'm trying to make a backup by mongodump.
The problem for me is, that mongoDb is running as a docker container, and the backup should be stored outside of the docker container.
I think the syntax for this is something like this:
docker run \
--rm \
-it \
--link DOCKER_CONTAINER_NAME:mongo_alias \
-v /backup:/backup \
mongo mongodump \
--host mongo_alias \
--out /backup/
But I'm not sure for the parameters I have to use...
This is what I get for my mongoDb container via docker ps:
7bee41bfa08a mongo:3.4 "docker-entrypoint..." 4 months ago Up 2 months 27017/tcp mongo_db
And this is my docker-compose file:
version: "3"
services:
mongo_db:
container_name: mongo_db
image: 'mongo:3.4'
restart: 'always'
volumes:
- '/opt/mongo/project/live:/data/db'
So it should look like this?
docker run \
--rm \
-it \
--link mongo_db:mongo_alias \ # mongo_alias can be choosen freely?
-v /backup:/backup \ # Don't understand /backup:/backup
mongo mongodump \
--host mongo_alias \
--out /backup/ # This is in the root of the server?
Define the backup to run via compose as well. This will create the new container on the same network as the main mongo container. If you have any compose network definitions you will need to duplicate them in each compose file.
Create a second compose file for the backup command: docker-compose-backup.yml
version: "3"
services:
mongo_db_backup:
image: 'mongo:3.4'
volumes:
- '/opt/mongo/project/live_backup:/backup'
command: |
mongodump --host mongo_db --out /backup/
Then run the backup
docker-compose -f docker-compose-backup.yml run mongo_db_backup
You can also do this without docker-composer, directly from your host
Backup all databases
docker exec -t your-db-container mongodump --host mongo_db --out /backup/
Restore all databases
Move your backup folder to your host volume folder
docker exec -t your-db-container mongorestore /backup/