mongo:
image: mongo
container_name: mongo
restart: always
ports:
- 27017:27017
networks:
default:
ipv4_address: 172.18.0.9
environment:
TZ: Asia/Shanghai
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: 123456
volumes:
- mongodata:/data/db
command: --auth
volumes:
esdata:
driver: local
mongodata:
networks:
default:
external:
name: net
docker exec -it mongo bash
mongo -uroot -p123456
use admin;
show users;
连接